ci: trim whitespace from tag input in release workflows#24
Conversation
The workflow_dispatch tag input had a leading space (" iii-lsp/v1.0.0")
which caused taiki-e/upload-rust-binary-action to fail with "release
not found" — softprops/action-gh-release trims the tag when creating
the release, but the upload action used the raw value with the space.
Use env var + xargs to trim whitespace and prevent shell injection.
📝 WalkthroughWalkthroughThree GitHub Actions release workflows are updated to normalize tag values by trimming whitespace before output. The tag resolution step now pipes the raw input through Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/release-lsp.yml (1)
33-41:⚠️ Potential issue | 🟡 MinorFail fast if the trimmed tag is empty.
If
RAW_TAGis only whitespace,TAGbecomes empty and later steps fail with less actionable errors. Add a guard immediately after Line [36].Suggested patch
run: | TAG=$(echo "$RAW_TAG" | xargs) + if [[ -z "$TAG" ]]; then + echo "::error::Tag is empty after trimming whitespace" + exit 1 + fi echo "tag=$TAG" >> "$GITHUB_OUTPUT"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release-lsp.yml around lines 33 - 41, The trimmed tag may be empty when RAW_TAG contains only whitespace; add a guard right after the TAG=$(echo "$RAW_TAG" | xargs) line to fail fast: check if TAG is empty (e.g., if [ -z "$TAG" ]), emit a clear error (echo "::error::Missing or empty tag from RAW_TAG") and exit non-zero (exit 1) so the workflow stops before the "Extract metadata from tag" (id: meta) step runs with an invalid TAG value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release-lsp-binary.yml:
- Around line 37-41: After trimming RAW_TAG into TAG, add a guard that checks if
TAG is empty or only whitespace and, if so, emit a clear error to stderr and
exit non‑zero before writing to GITHUB_OUTPUT; update the script that uses
RAW_TAG/TAG in the workflow's run block to validate TAG (using the trimmed TAG
variable) and fail early with a descriptive message so downstream
metadata/release jobs don't run with an empty TAG.
In @.github/workflows/release.yml:
- Around line 37-41: After trimming RAW_TAG into TAG, add a guard that checks
TAG is non-empty and fails the job with a clear message if empty; specifically,
after TAG=$(echo "$RAW_TAG" | xargs) validate TAG and only echo "tag=$TAG" to
GITHUB_OUTPUT when non-empty, otherwise print an explanatory error and exit
non-zero to stop the workflow early (use the existing RAW_TAG, TAG and
GITHUB_OUTPUT symbols).
---
Outside diff comments:
In @.github/workflows/release-lsp.yml:
- Around line 33-41: The trimmed tag may be empty when RAW_TAG contains only
whitespace; add a guard right after the TAG=$(echo "$RAW_TAG" | xargs) line to
fail fast: check if TAG is empty (e.g., if [ -z "$TAG" ]), emit a clear error
(echo "::error::Missing or empty tag from RAW_TAG") and exit non-zero (exit 1)
so the workflow stops before the "Extract metadata from tag" (id: meta) step
runs with an invalid TAG value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 08f26cdb-2e8c-4d5c-bee8-da479bdb1d24
📒 Files selected for processing (3)
.github/workflows/release-lsp-binary.yml.github/workflows/release-lsp.yml.github/workflows/release.yml
| env: | ||
| RAW_TAG: ${{ inputs.tag || github.ref_name }} | ||
| run: | | ||
| TAG="${{ inputs.tag || github.ref_name }}" | ||
| TAG=$(echo "$RAW_TAG" | xargs) | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
Guard against whitespace-only dispatch input.
Line [40] can produce an empty TAG; add an explicit check to fail with a clear error before metadata/release jobs run.
Suggested patch
run: |
TAG=$(echo "$RAW_TAG" | xargs)
+ if [[ -z "$TAG" ]]; then
+ echo "::error::Tag is empty after trimming whitespace"
+ exit 1
+ fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/release-lsp-binary.yml around lines 37 - 41, After
trimming RAW_TAG into TAG, add a guard that checks if TAG is empty or only
whitespace and, if so, emit a clear error to stderr and exit non‑zero before
writing to GITHUB_OUTPUT; update the script that uses RAW_TAG/TAG in the
workflow's run block to validate TAG (using the trimmed TAG variable) and fail
early with a descriptive message so downstream metadata/release jobs don't run
with an empty TAG.
| env: | ||
| RAW_TAG: ${{ inputs.tag || github.ref_name }} | ||
| run: | | ||
| TAG="${{ inputs.tag || github.ref_name }}" | ||
| TAG=$(echo "$RAW_TAG" | xargs) | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
Add an empty-tag guard after trimming.
After Line [40], validate TAG is non-empty so the workflow fails early with a clear message instead of failing downstream.
Suggested patch
run: |
TAG=$(echo "$RAW_TAG" | xargs)
+ if [[ -z "$TAG" ]]; then
+ echo "::error::Tag is empty after trimming whitespace"
+ exit 1
+ fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| env: | |
| RAW_TAG: ${{ inputs.tag || github.ref_name }} | |
| run: | | |
| TAG="${{ inputs.tag || github.ref_name }}" | |
| TAG=$(echo "$RAW_TAG" | xargs) | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| env: | |
| RAW_TAG: ${{ inputs.tag || github.ref_name }} | |
| run: | | |
| TAG=$(echo "$RAW_TAG" | xargs) | |
| if [[ -z "$TAG" ]]; then | |
| echo "::error::Tag is empty after trimming whitespace" | |
| exit 1 | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/release.yml around lines 37 - 41, After trimming RAW_TAG
into TAG, add a guard that checks TAG is non-empty and fails the job with a
clear message if empty; specifically, after TAG=$(echo "$RAW_TAG" | xargs)
validate TAG and only echo "tag=$TAG" to GITHUB_OUTPUT when non-empty, otherwise
print an explanatory error and exit non-zero to stop the workflow early (use the
existing RAW_TAG, TAG and GITHUB_OUTPUT symbols).
Summary
iii-lsp/v1.0.0release binary upload failed because theworkflow_dispatchtag input had a leading space (iii-lsp/v1.0.0)softprops/action-gh-releasetrimmed the space when creating the release, buttaiki-e/upload-rust-binary-actionused the raw value — sogh release upload " iii-lsp/v1.0.0"couldn't find the release taggediii-lsp/v1.0.0xargsto trim whitespace, and useenv:instead of inline${{ }}to avoid shell injectionTest plan
iii-lsp/v1.0.0release viaworkflow_dispatchafter mergingSummary by CodeRabbit