Skip to content

[ts-command-line] Fix env var name shown in EnvironmentVariableParser error messages#5831

Merged
iclanton merged 2 commits into
microsoft:mainfrom
LeSingh1:fix/ts-command-line-env-var-name-in-error-message
Jun 12, 2026
Merged

[ts-command-line] Fix env var name shown in EnvironmentVariableParser error messages#5831
iclanton merged 2 commits into
microsoft:mainfrom
LeSingh1:fix/ts-command-line-env-var-name-in-error-message

Conversation

@LeSingh1

Copy link
Copy Markdown
Contributor

When parseAsList encounters a malformed JSON array in an environment variable, it throws
two possible error messages. Both messages were accidentally interpolating the variable's
value (environmentValue) instead of the variable's name (envVarName). This means a user
who set MY_VAR='[u' would see:

The [u environment variable value looks like a JSON array but failed to parse: ...

instead of the expected:

The MY_VAR environment variable value looks like a JSON array but failed to parse: ...

The fix is a two-character change in each template string, swapping environmentValue for
envVarName. The existing test assertion and snapshot were written against the wrong output,
so those are corrected to match the intended behavior.

I noticed this while reading EnvironmentVariableParser.ts. No open issue existed for it
so I'm filing the fix directly. Happy to open a tracking issue first if that's preferred.

…e in error messages

When a list parameter's environment variable contained an invalid JSON
array, the two error messages in EnvironmentVariableParser.parseAsList
accidentally interpolated the variable's value (environmentValue) where
the variable's name (envVarName) was intended.  The result was confusing
messages like "The [u environment variable value looks like a JSON array
but failed to parse" instead of "The MY_VAR environment variable value
looks like a JSON array but failed to parse".

Update the two affected template strings to use envVarName, and correct
the corresponding test assertion and snapshot that were written to match
the old (wrong) output.
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
@iclanton iclanton enabled auto-merge (squash) June 12, 2026 19:48
@iclanton iclanton merged commit 83c2216 into microsoft:main Jun 12, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants