Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Failure if value contains an = (because line is split on all equals, not just first) #102

Closed
JamesJTC opened this issue Apr 4, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@JamesJTC
Copy link

JamesJTC commented Apr 4, 2024

Example:

DBSOCKET = "mysql+pymysql://{user}@LOCALHOST/myapp?unix_socket=/run/mysqld/mysqld.sock"

Expected behaviour: Successful generation of env.g.dart

Actual Output:

[SEVERE] envied_generator:envied on lib/env/env.dart:
  Bad state: Pattern matching error
  package:envied_generator/src/parser.dart 43:5      Parser.parseOne
  package:envied_generator/src/parser.dart 23:38     Parser.parse
  package:envied_generator/src/load_envs.dart 24:17  loadEnvs
  package:envied_generator/src/generator.dart 60:9   EnviedGenerator.generateForAnnotatedElement

Reason for failure:

String is split on all occurances of '=' and assumes the value will never have one.

parser.dart:

    /// Split the line into key and value.
    final [String lhs, String rhs] = stripped.split('=');

Suggested fix:

since the .env spec does not require any spaces around =, the only way to identify the separator is to only split on the first occurrence of the =.

Therefore, replace the use of the inbuilt string.split('=') with one that only splits on the first occurrence.

@JamesJTC
Copy link
Author

JamesJTC commented Apr 4, 2024

Apologies, realised you have fixed this, but unless people require envied: ^0.5.4+1 specifically it does not pull the update. may wish to do a minor version increment to ensure this is fixed?

(#100)

@JamesJTC JamesJTC closed this as completed Apr 4, 2024
@techouse
Copy link
Collaborator

techouse commented Apr 4, 2024

Apologies, realised you have fixed this, but unless people require envied: ^0.5.4+1 specifically it does not pull the update. may wish to do a minor version increment to ensure this is fixed?

I don't see how

envied: ^0.5.4

would fail to update to v0.5.4+1

@techouse techouse added the duplicate This issue or pull request already exists label Apr 4, 2024
@JamesJTC
Copy link
Author

JamesJTC commented Apr 4, 2024

@techouse my bad, for whatever reason the project didn't grab it when I ran it, but I tried cleaning and redownloading with ^0.5.4 and it did grab it that time. Mea Culpa.

@JamesJTC JamesJTC reopened this Apr 4, 2024
@JamesJTC JamesJTC closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants