fix: route error messages to stderr in varlock load to prevent JSON parse failures#495
fix: route error messages to stderr in varlock load to prevent JSON parse failures#495
varlock load to prevent JSON parse failures#495Conversation
🦋 Changeset detectedLatest commit: 6dd1bf6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/0eb370e9-d36d-4830-920e-b53ba282b734 Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
varlock load to prevent JSON parse failures
commit: |
|
@copilot - I believe this problem appeared for a user while using the dotenv drop-in replacement. Lets add a framework test - can be called "vanilla-node" which checks with a bad schema that it doesnt fail parsing json. |
|
@copilot - I believe this problem appeared for a user while using the dotenv drop-in replacement. Lets add a framework test - can be called "vanilla-node" which checks with a bad schema that it doesnt fail parsing json. |
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/3c2abdac-8058-4ad4-bab5-7251d77ed4db Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/3c2abdac-8058-4ad4-bab5-7251d77ed4db Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
Added a "vanilla-node" smoke test in commit New files:
|
When a plugin (e.g. AWS secrets) fails during
varlock load --format json-full --compact, error messages were written to stdout viaconsole.log, contaminating the JSON payload. Sinceimport 'varlock/config'captures stdout viaexecSyncand passes it directly toJSON.parse(), any non-JSON text causes a hard crash:Changes
showErrorLocationDetails— switchedconsole.log→console.errorcheckForSchemaErrors— switched all error output (console.log→console.error) for loading errors, schema errors, and stack tracescheckForConfigErrors— switched root decorator resolution error output toconsole.errorStdout is now exclusively used for the intended machine-readable output (JSON, env, shell formats), while all diagnostic error messages go to stderr.
Tests
Added a
vanilla-nodesmoke test that exercises the dotenv drop-in replacement (import 'varlock/config') with a bad schema (a@requiredvariable with no value):varlock load --format json-full stdout is valid JSON when schema has errors— runs the CLI command directly and asserts that stdout is either empty or valid JSON; error messages must only appear on stderrimporting varlock/config with a bad schema does not cause a JSON parse error— runs a plain Node.js script (node app.mjs) that importsvarlock/configand confirms the process fails with a proper schema error on stderr, not withSyntaxError: JSON Parse error: Unrecognized token '🚨'💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.