Skip to content

chore(ci): check LP bug reference syntax in conventional commit checks - #645

Draft
alemar99 wants to merge 1 commit into
canonical:masterfrom
alemar99:check-lp-reference-syntax-ci
Draft

alemar99 wants to merge 1 commit into
canonical:masterfrom
alemar99:check-lp-reference-syntax-ci

Conversation

@alemar99

Copy link
Copy Markdown
Contributor

Make sure that the format when specifying the LP bug reference is the one expected by the LP bug update workflow.

Make sure that the format when specifying the LP bug reference is the
one expected by the LP bug update workflow.
@alemar99
alemar99 requested a review from a team September 10, 2026 07:47
@alemar99 alemar99 changed the title ci: check LP bug reference syntax in conventional commit checks chore(ci): check LP bug reference syntax in conventional commit checks Sep 10, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[maas-code-reviewer review]

LLM-generated review from https://github.com/canonical/maas-code-reviewer.
Intended to assist a human reviewer, not replace one — suggestions may be
incorrect, please verify before acting.

This correctly implements a verification step to ensure developers specify Launchpad bug references in a way that the lp-bug-update workflow can parse. Using an environment variable (PR_BODY_ENV) for the PR body is a great security practice to prevent command injection.

I did spot a bug with the regular expression that will cause false positives with common English words ending in lp:, as well as a few small details regarding multi-line strings and PCRE sequences.

Comment thread .github/workflows/ci.yaml
PR_BODY="$PR_BODY_ENV"

# Same keywords as the lp-bug-update workflow.
if grep -qiP '\b(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b.*LP:\s*' <<< "$PR_BODY"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Because grep is using the -i (case-insensitive) flag, .*LP:\s* will match any string containing lp:, including common words like help:, gulp:, or scalp:.

For example, if a developer writes Fixes the typo in help:, this first grep will evaluate to true. The inner check on line 172 will then fail (since there is no number after it), causing a false positive that blocks the PR.

To fix this, anchor LP: to a word boundary by changing it to \bLP:\s*. (You should consider applying this fix to the lp-bug-update workflow as well, to prevent it from erroneously extracting a bug ID from something like Fixes the help: 123).

Additionally, note that grep operates line-by-line. This means the closing keyword and LP: must appear on the same line. A multi-line format like:

Fixes the issue.
LP: 12345

will be completely ignored by this check (and consequently by the lp-bug-update workflow). If you intend to require them to be on the same line, this behavior is perfectly fine.

Comment thread .github/workflows/ci.yaml

# Same keywords as the lp-bug-update workflow.
if grep -qiP '\b(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b.*LP:\s*' <<< "$PR_BODY"; then
if ! grep -qiP '\b(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b.*LP:\s*\K[0-9]+' <<< "$PR_BODY"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two minor points here:

  1. You should apply the same \bLP:\s* fix here to keep the regexes identical and prevent false positives.
  2. The \K escape sequence (which resets the match start) has no effect here because you are using the -q flag, which suppresses output and only checks for a match's existence. While it's harmless and keeps the pattern identical to the lp-bug-update workflow, it is technically unnecessary here.

@alemar99
alemar99 marked this pull request as draft September 10, 2026 07:59
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