[Bug] resolveConfigValue uses || instead of ?? — empty env vars return literal var name as credential #1468
RelaxJonh
started this conversation in
Bug reports
Replies: 1 comment
|
I've investigated this and prepared a fix on my fork: https://github.com/RelaxJonh/prime-agent/tree/fix/resolve-config-value-nullish-coalescing The fix is a 2-line change in const envValue = process.env[config];
- return envValue || config;
+ return envValue ?? config;Applied to both Happy to open a PR if the maintainers would like to review it. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent — credential resolution (
resolve-config-value.ts)What happened?
resolveConfigValue()andresolveConfigValueUncached()inpackages/coding-agent/src/core/resolve-config-value.tsuse||(logical OR) instead of??(nullish coalescing) when falling back from an environment variable to the literal config string:||treats empty string""as falsy, so when a user setsMY_API_KEY=""(explicitly empty), the function returns the literal environment variable name"MY_API_KEY"instead of""orundefined.Steps to reproduce
export TEST_API_KEY=""auth.jsonwith"key": "TEST_API_KEY"resolveConfigValue("TEST_API_KEY")undefinedor""(empty — should trigger missing-credential error)"TEST_API_KEY"(the literal string, used as the API key)Impact
unsetin some shells, or.envfiles withKEY=), the literal env var name is sent as the API key to the provider.resolveConfigValueOrThrow(line 99) callsresolveConfigValueUncachedand checks!== undefined, so it never throws — the empty env var silently becomes the literal name.Suggested fix
Replace
||with??in both functions:This preserves the existing behavior for
undefined(env var not set → use literal) while correctly handling empty strings (env var set to empty → return empty, triggering downstream missing-credential logic).Environment
2c34b82f8)All reactions