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

[BUG] Programmatic access to config validator (via env vars) is out of scope #1663

Open
5 tasks done
TheRealGramdalf opened this issue Aug 7, 2024 · 1 comment
Open
5 tasks done
Assignees
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working

Comments

@TheRealGramdalf
Copy link

Environment

Other (Specify below)

System

NixOS Unstable (Nixpkgs /b73c2221a46c13557b1b3be9c2070cc42cf01eb3)

Version

3.1.1+ (Git 0b1af9d)

Describe the problem

While attempting to package Dashy for NixOS, I tried to use yarn validate-config as part of the build process to validate that the configuration is correct before building the dashboard, which can often take several minutes.

In order to stop the build, however, a command needs to exit with a non-zero exit code - and as it currently stands, yarn validate-config exits with 0 whether or not the config is valid.

Looking into the config validator, there appears to be an environment variable set if the configuration is valid. In practice (by inserting a printenv), the variable seems to either be unset or out of scope after the validator exits, which makes programmatic access to the status harder.

Additional info

Using my (albeit limited) javascript knowledge, I tried to alter the validator script to exit with a non-zero code:

try { // Try to open and parse the YAML file
  config = yaml.load(fs.readFileSync(`./${process.env.USER_DATA_DIR || 'user-data'}/conf.yml`, 'utf8'));
  validate(config);
} catch (e) { // Something went very wrong...
  setIsValidVariable(false);
  logToConsole(bigError());
  printFileReadError(e);
+ process.exit(1);
}
module.exports = config;

...Which still seemed to exit with code 0 while config errors were present.

Please tick the boxes

@TheRealGramdalf TheRealGramdalf added the 🐛 Bug [ISSUE] Ticket describing something that isn't working label Aug 7, 2024
@TheRealGramdalf
Copy link
Author

TheRealGramdalf commented Aug 7, 2024

Additionally related to packaging with Nix (though unrelated to the config validator), I'm getting these errors when fetching the yarn packages to an offline cache:

success Set "yarn-offline-mirror" to "/nix/store/49a9m7wdssvxz91lcxvq8w6206b7cx4f-offline".
Done in 0.02s.
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-import@^2.22.1".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-jsx-a11y@^6.4.1".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-react@^7.21.5".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-react-hooks@^4 || ^3 || ^2.3.0 || ^1.7.0".
warning "eslint-config-airbnb > [email protected]" has unmet peer dependency "eslint-plugin-import@^2.22.1".
warning " > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
warning Workspaces can only be enabled in private projects.
[4/4] Rebuilding all packages...
warning Ignored scripts due to flag.
Done in 11.83s.

@liss-bot liss-bot added 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending and removed 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending labels Aug 7, 2024
@CrazyWolf13 CrazyWolf13 removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working
Projects
Status: Awaiting Triage
Development

No branches or pull requests

4 participants