Skip to content

Fix GCL_ array env vars not splitting semicolon-separated values - #1778

Merged
firecow merged 8 commits into
masterfrom
fix/semicolon-split-array-env-vars
Apr 3, 2026
Merged

Fix GCL_ array env vars not splitting semicolon-separated values#1778
firecow merged 8 commits into
masterfrom
fix/semicolon-split-array-env-vars

Conversation

@firecow

@firecow firecow commented Feb 26, 2026

Copy link
Copy Markdown
Owner
  • Fix GCL_VARIABLE and other array-type env vars not splitting semicolon-separated values (e.g. GCL_VARIABLE="VAR1=hello;VAR2=world")
  • Array keys derived from yargs at runtime — no hardcoded list to maintain
  • Simplify argv.ts: getStringArray() helper reduces getter boilerplate, early return in injectDotenv()
  • Fix regex backtracking vulnerability in variable getter (SonarCloud S5852)

Fixes #992

@firecow firecow self-assigned this Feb 26, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/argv.ts Outdated
@firecow
firecow force-pushed the fix/semicolon-split-array-env-vars branch from ee5745e to 591c423 Compare February 26, 2026 14:19
@firecow
firecow marked this pull request as draft February 27, 2026 15:47
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().
@firecow
firecow force-pushed the fix/semicolon-split-array-env-vars branch from 15f82ae to 7e8fb51 Compare February 28, 2026 14:03
@firecow firecow changed the title Fix array env vars not splitting multiple semicolon-separated values Fix GCL_ array env vars not splitting semicolon-separated values Feb 28, 2026
Replace super-linear regex flagged by SonarCloud (S5852) with
a simpler equivalent that avoids overlapping alternatives.
@firecow
firecow marked this pull request as ready for review February 28, 2026 14:26

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/test-cases/gcl-env-variable-split/integration.test.ts
Comment thread src/argv.ts Outdated
firecow and others added 5 commits February 28, 2026 16:32
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).
@sonarqubecloud

Copy link
Copy Markdown

@cedric-orange

Copy link
Copy Markdown

Do you have any idea when the merge will occurs ?

@firecow

firecow commented Apr 2, 2026

Copy link
Copy Markdown
Owner Author

@cedric-orange During easter 😄

@firecow
firecow merged commit e230024 into master Apr 3, 2026
12 of 14 checks passed
@firecow
firecow deleted the fix/semicolon-split-array-env-vars branch April 3, 2026 08:45
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Apr 7, 2026
This MR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Adoption](https://docs.renovatebot.com/merge-confidence/) | [Passing](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|---|---|
| [npm:gitlab-ci-local](https://github.com/firecow/gitlab-ci-local) | `4.70.0` → `4.70.1` | ![age](https://developer.mend.io/api/mc/badges/age/npm/gitlab-ci-local/4.70.1?slim=true) | ![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/gitlab-ci-local/4.70.1?slim=true) | ![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/gitlab-ci-local/4.70.0/4.70.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/gitlab-ci-local/4.70.0/4.70.1?slim=true) |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>firecow/gitlab-ci-local (npm:gitlab-ci-local)</summary>

### [`v4.70.1`](https://github.com/firecow/gitlab-ci-local/releases/tag/4.70.1)

[Compare Source](firecow/gitlab-ci-local@4.70.0...4.70.1)

#### What's Changed

- fix: GCL\_ array env vars not splitting semicolon-separated values by [@&#8203;firecow](https://github.com/firecow) in [#&#8203;1778](firecow/gitlab-ci-local#1778)
- fix: strip ports and digests from service aliases by [@&#8203;bidord](https://github.com/bidord) in [#&#8203;1820](firecow/gitlab-ci-local#1820)
- fix: SonarCloud code smells by [@&#8203;firecow](https://github.com/firecow) in [#&#8203;1822](firecow/gitlab-ci-local#1822)
- chore(deps): update github/codeql-action action to v4.34.0 by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1807](firecow/gitlab-ci-local#1807)
- chore(deps): update github/codeql-action action to v4.35.1 by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1808](firecow/gitlab-ci-local#1808)
- chore(deps): lock file maintenance by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1811](firecow/gitlab-ci-local#1811)
- build(deps): bump path-to-regexp from 0.1.12 to 0.1.13 in /examples/docker-compose-nodejs by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;1816](firecow/gitlab-ci-local#1816)
- chore(deps): update sonarsource/sonarqube-scan-action action to v7.1.0 by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1818](firecow/gitlab-ci-local#1818)
- chore(deps): update dependency typescript to v6 by [@&#8203;renovate](https://github.com/renovate)\[bot] in [#&#8203;1812](firecow/gitlab-ci-local#1812)

#### New Contributors

- [@&#8203;bidord](https://github.com/bidord) made their first contribution in [#&#8203;1820](firecow/gitlab-ci-local#1820)

**Full Changelog**: <firecow/gitlab-ci-local@4.70.0...4.70.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDQuOCIsInVwZGF0ZWRJblZlciI6IjQzLjEwNC44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
kevingerman pushed a commit to kevingerman/gitlab-ci-local that referenced this pull request Apr 10, 2026
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.

GCL_VARIABLE multiple key/value pairs not working

3 participants