Skip to content

Report an "env" array as a config error instead of crashing - #1518

Open
kwy404 wants to merge 1 commit into
google:mainfrom
kwy404:fix-env-array-crash
Open

kwy404 wants to merge 1 commit into
google:mainfrom
kwy404:fix-env-array-crash

Conversation

@kwy404

@kwy404 kwy404 commented Sep 25, 2026

Copy link
Copy Markdown

When a script's "env" is not an object, #processEnv pushes an "Expected an object" failure but keeps going. If the value is a non-empty array, such as "env": ["FOO"], the loop then treats each array element as an object property, finds no key/value children, and throws Internal error: expected object JSON node children to be key/val pairs. The CLI dies with that stack trace instead of printing the diagnostic, and IdeAnalyzer.getDiagnostics rejects with the same error, so the editor never shows it either. An empty array (the case covered by the existing test) has no children, so it already worked.

This returns right after reporting the "Expected an object" failure, like the other #process* helpers do after a type error.

Added a test in errors-analysis.test.ts next to the existing "env must be an object" test, using "env": ["FOO"]. It fails before the change (the stderr is the internal error stack) and passes after. Also added a CHANGELOG entry under Unreleased > Fixed.

A non-empty array such as "env": ["FOO"] reported "Expected an object" but
then kept walking the array as if it were an object and threw an internal
error. Return after reporting the failure.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant