fix(ci): registry monitor cold-start crash (empty latest.json)#15
Merged
Conversation
The first run crashed with JSONDecodeError: the restore step's '>' redirect created an empty latest.json before 'git show' ran, and on a cold start (no data branch yet) that 0-byte file reached SnapshotStore.load_latest(). Guard with 'git cat-file -e' *before* the redirect so the baseline file is only written when it actually exists on the data branch, and 'rm -f' any stray baseline first so an empty file can never reach the monitor. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNoTXU8k3pfSBzR7aJubqL
The name 'registry-monitor' was already taken by an old feature branch (full codebase copy) from the initial monitor development. Point the daily sweep at a distinct 'registry-snapshots' branch instead so the snapshot history is clean and doesn't pile on top of stale code. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNoTXU8k3pfSBzR7aJubqL
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
The first
Registry Monitorrun failed withJSONDecodeError: Expecting value: line 1 column 1 (char 0).Cause: the "Restore snapshot baseline" step used
git show …:latest.json > latest.json. The shell creates/truncates the redirect target beforegit showruns, so on a cold start (noregistry-monitordata branch yet) it left an empty 0-bytelatest.json, whichSnapshotStore.load_latest()then tried tojson.loads()→ crash.Fix:
rm -fany stray baseline first, and guard withgit cat-file -ebefore the redirect solatest.jsonis only written when it genuinely exists on the data branch. Cold start now correctly diffs against nothing.The secret wiring is confirmed working — the run log showed
MALWAR_ANTHROPIC_API_KEY: ***, so the LLM layer will engage once this lands.Type of Change
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01DNoTXU8k3pfSBzR7aJubqL
Generated by Claude Code