Skip to content

fix(parser): anchor comment directives correctly and quote injected descriptions - #1896

Merged
firecow merged 5 commits into
masterfrom
fix-comment-directive-anchor
Jul 31, 2026
Merged

fix(parser): anchor comment directives correctly and quote injected descriptions#1896
firecow merged 5 commits into
masterfrom
fix-comment-directive-anchor

Conversation

@firecow

@firecow firecow commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Comment directives were anchored with /\w:/, which also matched a word: inside a comment, so a multi-line # @Description containing a colon attached the injected key to the wrong job; directives now anchor only on unindented non-comment keys and injected descriptions are quoted so a colon in the text cannot produce invalid YAML.

The description-quoting bug is present on master independently of this change.


Summary by cubic

Fixed directive injection to skip comment lines, anchor on real top-level job keys (including names with spaces, slashes, and quoted keys), and quote description values. Prevents mis-anchoring and invalid YAML, removing the "duplicated mapping key detected" warning.

  • Bug Fixes
    • Scan only real top-level keys with /^[^\s#].*:/; ignore # lines and indented keys. Supports names with spaces, slashes, and quoted keys.
    • Quote injected gclDescription values to handle colons and quotes in descriptions.

Written for commit 0792fc5. Summary will update on new commits.

Review in cubic

firecow added 4 commits July 9, 2026 14:48
The @Description/@Interactive/@InjectSSHAgent/@NoArtifactsToSource
injection used /\w:/ to find the job to attach a pending directive to.
That regex also matches a colon inside a comment line, so a multi-line
'# @description ...: ...' block (or any comment containing 'word:')
was treated as the anchor. The 2-space 'gclDescription:' line then got
spliced in after a comment, landing on the previous job — producing a
duplicate mapping key and the 'duplicated mapping key detected! Values
will be overwritten!' warning.

Skip comment lines entirely when scanning for the anchor, and only
anchor on a real top-level key (/^[\w.$-]+:/) so indented keys and
comments can never be mistaken for a job.
The top-level key anchor rejected any name outside [\w.$-], so a
directive above "deploy to prod:" or "build/image:" was never consumed
and drifted onto the next matching job.
A description containing a colon was spliced in unquoted and produced
invalid YAML.
Asserts each @description lands on its own job, across a multi-line
comment whose text contains a colon, a job name with spaces and one
with a slash.
@firecow
firecow marked this pull request as ready for review July 31, 2026 07:43

@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.

No issues found across 3 files

Re-trigger cubic

The widened anchor newly matches quoted keys, which neither master nor
the original anchor did.
@firecow firecow changed the title fix(parser): don't anchor comment directives on comment lines fix(parser): anchor comment directives correctly and quote injected descriptions Jul 31, 2026
@sonarqubecloud

Copy link
Copy Markdown

@firecow
firecow merged commit 8265001 into master Jul 31, 2026
16 checks passed
@firecow
firecow deleted the fix-comment-directive-anchor branch July 31, 2026 08:31
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 11, 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.73.0` → `4.74.0` | ![age](https://developer.mend.io/api/mc/badges/age/npm/gitlab-ci-local/4.74.0?slim=true) | ![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/gitlab-ci-local/4.74.0?slim=true) | ![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/gitlab-ci-local/4.73.0/4.74.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/gitlab-ci-local/4.73.0/4.74.0?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.74.0`](https://github.com/firecow/gitlab-ci-local/releases/tag/4.74.0)

[Compare Source](firecow/gitlab-ci-local@4.73.0...4.74.0)

#### What's Changed

- fix: introduce per-job cert volume with %gcl% token by [@&#8203;ticapix](https://github.com/ticapix) in [#&#8203;1877](firecow/gitlab-ci-local#1877)
- fix: pull registry probe image before the timed readiness check by [@&#8203;firecow](https://github.com/firecow) in [#&#8203;1904](firecow/gitlab-ci-local#1904)
- fix(parser): anchor comment directives correctly and quote injected descriptions by [@&#8203;firecow](https://github.com/firecow) in [#&#8203;1896](firecow/gitlab-ci-local#1896)

**Full Changelog**: <firecow/gitlab-ci-local@4.73.0...4.74.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, 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 [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
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