Skip to content

Exclude synced static/api*.json from whitespace pre-commit hooks#3628

Merged
matthewhelmke merged 1 commit into
chainguard-dev:mainfrom
matthewhelmke:matthewhelmke/fix-precommit-autodocs-api-json
Jul 23, 2026
Merged

Exclude synced static/api*.json from whitespace pre-commit hooks#3628
matthewhelmke merged 1 commit into
chainguard-dev:mainfrom
matthewhelmke:matthewhelmke/fix-precommit-autodocs-api-json

Conversation

@matthewhelmke

Copy link
Copy Markdown
Collaborator

Problem

The AutoDocs PR #3626 failed the required pre-commit check — a job that has always passed. The failing hook is end-of-file-fixer, on four files:

static/api.json
static/api-v1.json
static/api-v2alpha1.json
static/api-v2beta1.json

These are OpenAPI specs that .github/actions/integrate-platform-docs syncs verbatim from cloud storage (gsutil ... enforce-openapi/api*.json static/), and the generator emits them without a trailing newline. They've always lacked one; prior AutoDocs runs simply didn't change them, so they stayed out of the pre-commit diff. This run updated the spec, pulling them into the changed-file set, and end-of-file-fixer rewrote them — failing the check on content the docs team can't hand-fix (the next sync clobbers any newline we add).

Fix

Exclude static/api*.json from trailing-whitespace and end-of-file-fixer, mirroring the existing chainctl-docs exclusion — same rationale: generated, synced verbatim, fixes don't survive the next sync. Each exclude becomes a verbose ((?x)) regex covering both paths.

Verification

  • Regex tested against the four files plus near-misses (static/apidocs/x.json, static/api.json.bak) — matches only the intended specs, no over-match.
  • pre-commit run end-of-file-fixer --files static/api*.json README.md now passes (the specs are skipped; normal files still checked).
  • Config-only change; check-yaml and the full local hook suite pass.

Once this merges, the next AutoDocs run (or a rebase of #3626 onto updated main) will pass the check.


Created in collaboration with Claude Code running Opus 4.8 on 2026-07-23.

The AutoDocs job syncs OpenAPI specs (static/api*.json) verbatim from
cloud storage via .github/actions/integrate-platform-docs, and the
generator emits them without a trailing newline. When a sync changes
those files, they enter the pre-commit diff and end-of-file-fixer
rewrites them, failing the required pre-commit check on an
otherwise-mergeable automated PR (e.g. chainguard-dev#3626).

Exclude static/api*.json from trailing-whitespace and end-of-file-fixer,
mirroring the existing chainctl-docs exclusion: both are generated,
synced verbatim, and any fix the hooks apply is clobbered on the next
sync. Switch each exclude to a verbose regex covering both paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@matthewhelmke
matthewhelmke requested review from a team as code owners July 23, 2026 12:28
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for ornate-narwhal-088216 ready!

Name Link
🔨 Latest commit 90b89f7
🔍 Latest deploy log https://app.netlify.com/projects/ornate-narwhal-088216/deploys/6a6208ef22afe700089a762b
😎 Deploy Preview https://deploy-preview-3628--ornate-narwhal-088216.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@matthewhelmke

Copy link
Copy Markdown
Collaborator Author

These files have always lacked a trailing newline and worked.
The linter just started checking for this and is failing them.
The fix is to exclude these files from the linter as was done earlier for the automated chainctl files.

@matthewhelmke
matthewhelmke merged commit c3bd2dc into chainguard-dev:main Jul 23, 2026
7 checks passed
@matthewhelmke
matthewhelmke deleted the matthewhelmke/fix-precommit-autodocs-api-json branch July 23, 2026 13:35
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