Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/ci-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ jobs:
any_code:
- '!**/*.md'

- name: Get PR labels
id: pr-labels
uses: mydea/pr-labels-action@fn/bump-node20

outputs:
commit_label: '${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}'
# Note: These next three have to be checked as strings ('true'/'false')!
Expand All @@ -86,7 +82,8 @@ jobs:
# When merging into master, or from master
is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }}
has_gitflow_label:
${{ github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' Gitflow ') }}
${{ github.event_name == 'pull_request' && contains(toJSON(github.event.pull_request.labels.*.name), 'Gitflow')
}}
force_skip_cache:
${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' &&
contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ')) }}
contains(toJSON(github.event.pull_request.labels.*.name), 'ci-skip-cache')) }}
Comment on lines +85 to +89
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The use of toJSON() with contains() causes substring matching on the label list, not exact element matching. This can lead to incorrect label detection.
Severity: MEDIUM

Suggested Fix

Remove the toJSON() function call from the expression. Use contains(github.event.pull_request.labels.*.name, 'label-name') directly to perform an exact match against the elements in the label array, ensuring correct conditional logic in the CI workflow.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .github/workflows/ci-metadata.yml#L85-L89

Potential issue: The workflow checks for pull request labels using
`contains(toJSON(github.event.pull_request.labels.*.name), 'some-label')`. The
`toJSON()` function converts the label array into a single JSON string. Consequently,
`contains()` performs a case-insensitive substring search on this string instead of an
exact match on array elements. For example, if checking for the label `'Gitflow'`, a PR
with a label like `'No-Gitflow'` would incorrectly return `true` because `'Gitflow'` is
a substring of the JSON string `["No-Gitflow","bug"]`. This could cause CI jobs to be
skipped or run incorrectly based on partial label names.

Did we get this right? 👍 / 👎 to inform future reviews.

Loading