Conversation
PRE_COMMIT_SKIP passed from workflow inputs using YAML folded block scalars contains newlines. Stripping spaces alone leaves trailing newlines on hook IDs. This caused pre-commit to fail matching hook IDs in SKIP, running hooks like trivy-licenses in CI when they were intended to be skipped. Strip all whitespace using tr before passing to pre-commit. ENG-9724 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Replace echo with printf to safely preserve option-looking hook IDs.
Pull request overview
Updates the pre-commit action to remove all whitespace from PRE_COMMIT_SKIP before invoking pre-commit.
Changes:
- Sanitizes whitespace with
tr -d '[:space:]'. - Exports the normalized value as
SKIP.
File summaries
| File | Summary | Review status |
|---|---|---|
.github/actions/pre-commit/action.yaml |
Sanitizes and exports PRE_COMMIT_SKIP. |
Moderate issue: echo may interpret -n or -e as options; use printf. |
Review details
Suppressed comments (1)
.github/actions/pre-commit/action.yaml:196
echostill parses option-looking input after the fixed-n; for example, aPRE_COMMIT_SKIPvalue of exactly-nor-eis consumed as an echo option and becomes empty, so that hook ID is not passed topre-commit. Useprintffor data-safe emission before applyingtr.
SKIP="$(echo -n "${PRE_COMMIT_SKIP:-}" | tr -d '[:space:]')"
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PRE_COMMIT_SKIP passed from workflow inputs using YAML folded block scalars (>-) contains newlines.
${PRE_COMMIT_SKIP// /} only stripped ASCII spaces, leaving trailing newlines (\n) attached to hook IDs (e.g. trivy-licenses\n). Because pre-commit matches hook IDs strictly, hook IDs with trailing newlines failed to match, causing hooks like trivy-licenses to execute in CI instead of being skipped.
This PR strips all whitespace using tr -d '[:space:]' before passing SKIP to pre-commit.
Jira: ENG-9724