Repository navigation
fix(monitor): match storage not-found errors returned over the wire - #1474
Robbie Cronin (robert-cronin) wants to merge 1 commit into
Conversation
Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the repository monitor error-handling changes.
No open issues 🎉
What changed in this PR
Fixes repository monitor error handling for remote storage backends, allowing runs to proceed when pull requests have no existing monitor records.
Changes:
- Uses
errors.Isfor not-found and duplicate-create conflict detection. - Adds structured logging for failed monitor runs.
- Adds regression tests for wire-decoded errors and typed conflicts.
| File | Description |
|---|---|
| internal/controller/repositorymonitor_workflow.go | Detects duplicate mutations using typed conflicts. |
| internal/controller/repositorymonitor_wire_not_found_test.go | Tests not-found matching and first-run review creation. |
| internal/controller/repositorymonitor_mutation_conflict_test.go | Tests conflict handling without driver-specific wording. |
| internal/controller/repositorymonitor_controller.go | Fixes not-found detection and logs run failures. |
Review effort: Balanced
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
The repository monitor recognizes a missing storage record with
errorsIsStoreNotFound, which compared the error by identity:err == store.ErrNotFound. The embedded SQLite store returns the bare sentinel, so this works there. A storage backend reached over the storage wire returns the decoded errorremoteError{sentinel: storagev1.ErrNotFound}(pkg/storage/v1/wire/errors.go). Its text is "not found" anderrors.Ismatches it, but the identity check doesn't.The first place this shows is a monitor run on a dataset that has no item yet for an open pull request. This happens on a fresh dataset, and after the storage binding changes to a dataset that lacks an earlier review's records.
processPullRequestInventoryRuncallsGetMonitorItemfor the first selected pull request, treats its not-found as a real error, and fails the whole run with[run_failed] not found. Nothing is reviewed, no readiness status is posted, and the controller logs nothing. Every later run fails the same way until the item exists, which never happens, because the failing read is what would create it.internal/controller/repositorymonitor_controller.go:errorsIsStoreNotFounduseserrors.Is(err, store.ErrNotFound), so it matches the bare sentinel, wrapped sentinels and wire-decoded errors. A failed run now also logs the error, the run ID and the failure state; until nowrun_failedwas recorded only as a monitor event and the status condition.internal/controller/repositorymonitor_workflow.go:recordRepositoryMonitorGitHubMutationtreated a create error as an already-existing record only when its text contained "constraint", which is SQLite wording. It now uses the storage contract's typedstore.ErrConflict, which every backend must return for a duplicate create (storagetestalready requires it). Other errors still fail the call.Other sites checked (no change needed)
errorsIsStoreNotFound(repositorymonitor_inventory.go,repositorymonitor_issue_inventory.go,repositorymonitor_repair.go×8, and the delete path inrepositorymonitor_controller.go) read or delete a single record and mean "the record is absent".errors.Isgives every one of them its intended meaning.==/!=against a storage sentinel finds onlyacp_storage_hold.go, inside anIs(target error) boolmethod, where comparing the target by identity is the correct contract.Tests
TestErrorsIsStoreNotFoundMatchesWrappedSentinel: the bare sentinel, a%w-wrapped sentinel and a not-found decoded by the real storage wire (wiretest) all match; a conflict, an unrelated "not found" string and nil do not. With the identity check restored, the wrapped and wire-decoded cases fail.TestRepositoryMonitorFirstRunSelectsPullRequestWhenItemMissingOverStorageWire: the run's monitor-item read returns the wire-decoded not-found; the run must succeed, select the pull request and create its review Task. With the identity check restored, the run fails with[run_failed] storagefault: state.v1 GetMonitorItem: not found.TestRepositoryMonitorMutationDuplicateCreateUsesConflictContract: a typed conflict without driver wording is accepted as an existing record; a non-conflict error containing "constraint" is returned.Verification
go test ./internal/controller/ -run 'TestErrorsIsStoreNotFound|TestRepositoryMonitorFirstRunSelectsPullRequestWhenItemMissingOverStorageWire|TestRepositoryMonitorMutationDuplicateCreate' -race: passes. The wider-run 'RepositoryMonitor' -racerun passes exceptTestRepositoryMonitorEvidenceSanitizerStaysFast, a wall-clock budget test for the CI-evidence sanitizer that this change does not touch; it passes without-race.make lint-fixand full-treegolangci-lint run(root andpkg/storage): 0 issues.make lint-comments: passes.$autoreview(claude, branch, P1): clean, no accepted findings.Summary by CodeRabbit