Skip to content

fix(deps): sanitize all whitespace in PRE_COMMIT_SKIP - #115

Closed
alexpriv8 wants to merge 1 commit into
masterfrom
fix/pre-commit-skip-sanitize
Closed

alexpriv8 wants to merge 1 commit into
masterfrom
fix/pre-commit-skip-sanitize

Conversation

@alexpriv8

Copy link
Copy Markdown
Contributor

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

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>
Copilot AI lite review requested due to automatic review settings September 14, 2026 01:05

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

🔵 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

  • echo still parses option-looking input after the fixed -n; for example, a PRE_COMMIT_SKIP value of exactly -n or -e is consumed as an echo option and becomes empty, so that hook ID is not passed to pre-commit. Use printf for data-safe emission before applying tr.
        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.

@alexpriv8 alexpriv8 closed this Sep 14, 2026
@alexpriv8
alexpriv8 deleted the fix/pre-commit-skip-sanitize branch September 14, 2026 01:25
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.

2 participants