ci: auto-repair invalid JSON in PRs and on direct pushes to main - #247
Open
Core447 wants to merge 13 commits into
Open
ci: auto-repair invalid JSON in PRs and on direct pushes to main#247Core447 wants to merge 13 commits into
Core447 wants to merge 13 commits into
Conversation
The JSON check previously only reported syntax errors; it didn't block merges and couldn't fix anything. This adds: - scripts/validate_json.py: validates the top-level *.json files, with a --fix mode that repairs minor syntax issues (trailing commas, etc.) via json_repair, and a --restore-fallback mode that reverts a file to its last known-good version from git history if a repair isn't safe (e.g. it would drop most of the entries). - On pull_request (same-repo branches): auto-repairs and pushes the fix back to the PR branch; still fails the check if something can't be fixed, so it can be made a required status check to block merging. - On push to main (direct commits): auto-repairs, falling back to restoring the last known-good version, so main is never left pointing at broken JSON that the app would choke on. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…urrently, see PR)
…token The default GITHUB_TOKEN deliberately doesn't trigger new workflow runs when it pushes (anti-recursion protection). Verified this live on PR #247: the fix commit landed but never got its own check run, which would permanently block merging once this becomes a required status check. Push with STORE_AUTOMATION_TOKEN instead so the fix commit re-triggers CI and reports its own green check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
limitusus/json-syntax-checkcheck with a homegrownscripts/validate_json.py.json_repairand pushed back to the PR as a fix commit. If it can't be safely repaired, the check fails.main, it tries the same repair, and if that isn't safe (e.g. it would drop most entries), it restores the file to the last version in git history that parsed as valid JSON — somainis never left pointing at broken JSON that the app would choke on.Verified live on this PR
Icons.json(trailing comma) on a same-repo branch → the workflow detected it, repaired it withjson_repair, and pushed the fix commit back automatically. Confirmed multiple times.STORE_AUTOMATION_TOKEN(not the defaultGITHUB_TOKEN), since GITHUB_TOKEN pushes don't re-trigger workflow runs.Known open issue — do not make this a required status check yet
Even using
STORE_AUTOMATION_TOKEN(confirmed to be a valid, non-empty secret), the auto-fix commit is not reliably getting its own new check run in testing — same symptom as with the default token. Root cause isn't nailed down (ruled out: token being empty/misconfigured). Until this is understood, making this check required onmaincould leave a PR stuck showing no status for its current HEAD even though the file is already valid, which would block merges instead of just protecting them. Recommend holding off on the branch-protection change until this is resolved or someone confirms the behavior is more reliable outside of rapid back-to-back test pushes.Test plan
scripts/validate_json.pyrepairs a trailing-comma break inIcons.jsonand leaves it valid.--restore-fallback.