Skip to content

Trim whitespace from codeql_version input in update-codeql-version workflow - #220

Merged
felickz merged 3 commits into
mainfrom
copilot/fix-github-actions-validation
Aug 25, 2026
Merged

Trim whitespace from codeql_version input in update-codeql-version workflow#220
felickz merged 3 commits into
mainfrom
copilot/fix-github-actions-validation

Conversation

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The Validate and normalize version input step stripped an optional leading v but never trimmed whitespace, so a dispatched value of " 2.26.3" failed the ^[0-9]+\.[0-9]+\.[0-9]+$ check with codeql_version must look like X.Y.Z, got: 2.26.3.

Changes

  • Trim before validating: leading and trailing POSIX whitespace is stripped from inputs.codeql_version before the v prefix removal and the X.Y.Z regex check.
  • Error message reports the normalized value: uses $VERSION instead of re-interpolating ${{ inputs.codeql_version }}, so the reported value is the one that actually failed the check, and the step interpolates the workflow expression into shell only once.
VERSION="${{ inputs.codeql_version }}"
VERSION="${VERSION#"${VERSION%%[![:space:]]*}"}" # trim leading whitespace
VERSION="${VERSION%"${VERSION##*[![:space:]]}"}" # trim trailing whitespace
VERSION="${VERSION#v}" # tolerate an accidental leading "v"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  echo "::error::codeql_version must look like X.Y.Z, got: $VERSION"
  exit 1
fi

2.26.3 and v2.26.3 remain accepted; 2.26, 2.26.3.4, values with internal whitespace, and empty/whitespace-only input are still rejected.

Tests

No test added. The repository has no harness for exercising inline workflow shell steps (.github/scripts/*.sh have no accompanying test suite), so the change was verified by extracting the step script and running it against the accept/reject cases above.

Copilot AI and others added 2 commits August 17, 2026 19:33
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GitHub Actions workflow validation for codeql version Trim whitespace from codeql_version input in update-codeql-version workflow Aug 17, 2026
Copilot AI requested a review from felickz August 17, 2026 19:35
@felickz
felickz marked this pull request as ready for review August 25, 2026 20:56
Copilot AI lite review requested due to automatic review settings August 25, 2026 20:56
@felickz
felickz merged commit 5330bdb into main Aug 25, 2026
14 of 21 checks passed
@felickz
felickz deleted the copilot/fix-github-actions-validation branch August 25, 2026 20:56
Copilot stopped reviewing on behalf of felickz due to an error August 25, 2026 20:56

Copilot AI 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.

Pull request overview

Note

Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.

Updates the CodeQL version validation step to be more tolerant of user input formatting while keeping strict semantic version checks.

Changes:

  • Trim leading/trailing whitespace from the codeql_version input before validation.
  • Improve normalization by continuing to accept an accidental leading v.
  • Adjust the validation error message to print the post-processed version.
Show a summary per file
File Description
.github/workflows/update-codeql-version.yml Normalizes and validates the CodeQL version input more robustly in the workflow step.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Lite

VERSION="${VERSION#v}" # tolerate an accidental leading "v"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::codeql_version must look like X.Y.Z, got: ${{ inputs.codeql_version }}"
echo "::error::codeql_version must look like X.Y.Z, got: $VERSION"
@@ -54,9 +54,11 @@ jobs:
run: |
set -euo pipefail
VERSION="${VERSION#"${VERSION%%[![:space:]]*}"}" # trim leading whitespace
VERSION="${VERSION%"${VERSION##*[![:space:]]}"}" # trim trailing whitespace
VERSION="${VERSION#v}" # tolerate an accidental leading "v"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
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.

3 participants