Fix GCL_ array env vars not splitting semicolon-separated values#1778
Open
Fix GCL_ array env vars not splitting semicolon-separated values#1778
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/argv.ts">
<violation number="1" location="src/argv.ts:115">
P1: Bug: `flatMap` splitting on array elements corrupts CLI values containing semicolons. When multiple CLI flags are used (e.g., `--variable "MY_VAR=host=db;port=5432"`), the CLI framework already parses them into individual array elements. Splitting those elements on `;` corrupts values that legitimately contain semicolons (connection strings, CSS, etc.). The old code correctly left arrays untouched — only string inputs (from env vars) should be split.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
ee5745e to
591c423
Compare
When array options (--variable, --volume, etc.) are set via GCL_* environment variables with semicolon-separated values, yargs wraps the entire string as a single array element. This adds semicolon splitting for all array-type options derived from yargs at runtime. Also simplifies argv.ts: extracts getStringArray() helper to reduce repeated array/string normalization in getters, and uses early return in injectDotenv().
15f82ae to
7e8fb51
Compare
Replace super-linear regex flagged by SonarCloud (S5852) with a simpler equivalent that avoids overlapping alternatives.
Contributor
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/test-cases/gcl-env-variable-split/integration.test.ts">
<violation number="1" location="tests/test-cases/gcl-env-variable-split/integration.test.ts:170">
P2: This test doesn't verify what its name claims. It passes already-split values (`["VAR1=hello", "VAR2=world"]`) directly to `handler()` rather than providing a semicolon-joined `GCL_VARIABLE` env var. The `splitSemicolonEnvVars` middleware is never exercised. To actually test env-split → handler integration, set `process.env.GCL_VARIABLE` (or mock it) and pass an unsplit argv.</violation>
</file>
<file name="src/argv.ts">
<violation number="1" location="src/argv.ts:125">
P2: Potential `TypeError` crash if a non-string, non-array value is stored in the map (e.g. `VOLUME=true` in a `.env` file gets stored as boolean `true` by `injectDotenv`). The old getters checked `typeof val == "string"` before calling `.split()`. Consider adding a type guard.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The test claimed to verify that env-split variables reach the handler, but passed pre-split values directly. Now passes the unsplit value and calls splitSemicolonEnvVars before handler, actually testing the middleware.
Resolves SonarCloud S3358 (nested ternary operation).
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



GCL_VARIABLEand other array-type env vars not splitting semicolon-separated values (e.g.GCL_VARIABLE="VAR1=hello;VAR2=world")argv.ts:getStringArray()helper reduces getter boilerplate, early return ininjectDotenv()Fixes #992