CXH-144: do not fail the PagerDuty sync on 404 schedule-not-found #39
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #39"
general
weight: 0.35
c1-squire-dev[bot]
PagerDuty schedules can be deleted while a sync is running. Until now that
failed the whole sync with a 404 "Schedule Not Found" error, and the only
recovery was re-running it from the support dashboard. A schedule that stops
resolving between the connector's list phase and its per-schedule grants phase
is a normal race, not a broken credential or a dead API — this change treats
it that way: the connector now skips the vanished schedule's on-call grants
and finishes the sync. Everything the ticket asked for in one sentence: we
should not error on 404.
Linear: CXH-144
What was asked
The Gemini_Trust tenant's sync failed listing on-call users with 404 "Schedule
Not Found" (tenant 35elOxCryc76IdzTjP9zdPIttUF, app 36ZPL4Yfh2Yt9UJQUBZhXiin5Io).
The issue was only recoverable by manually re-running the sync from the support
dashboard. The acceptance bar from the ticket: a 404 on that listing must not
fail the sync — handle it gracefully so no dashboard re-run is needed.
What changed
The fix follows the connector's own error-handling rules
(
patterns-error-handling.mdRule 4,ci-review.mdS5/S6): a 404 may beskipped only when it is about the item being fetched, and only once the
vendor's 404 semantics are established in the code. Both halves are in the
diff.
pkg/connector/errors.goWhere:
notFoundOnItem~L39-52, afterwrapPagerDutyError~L13What changed
notFoundOnItem(err)wrapserrors.Asintopagerduty.APIErrorandapiErr.NotFound(), which the vendored SDK(go-pagerduty v1.8.0,
client.go:234-237) defines as HTTP 404 OR vendorerror code 2100.
404 means the addressed object is gone; permission denial is 403. It
cross-references
wrapPagerDutyError, which already maps the samepredicate to gRPC
codes.NotFound.wrapPagerDutyErroritself isunchanged.
Why
guard: on APIs that answer 404 for authorization failures (GitHub, some
SCIM servers), a 404 skip silently wipes data. Establishing it once in a
named, tested helper keeps the guard honest and makes the next call site
with the same shape a two-line change.
pkg/connector/schedule.goWhere:
Grantsguard ~L183-196, at theListOnCallUsersWithContext~L176error branch
What changed
return wrapPagerDutyError("failed to list on-callusers", err) became a two-way branch: on a genuine 404, one Debug log line
naming the schedule, then
return rv, "", nil, nil— the member grantsalready built from the resource profile still emit; only the on-call grants
of the vanished schedule are dropped. Every other error still fails the
sync through
wrapPagerDutyErrorunchanged.schedule: the call is a single-object GET of
/schedules/{id}/users, sothere is no second object the 404 could be about.
Why
is the correct state, and returning the error (the old behavior) fails the
whole sync and buckets nothing. Skipping on any other error class would be
the destructive shape — a 401/403/429 might be about every schedule on the
page — so they keep failing.
pkg/connector/user.goWhere:
Delete~L185What changed
user.Delete's inline 404 guard now calls the sharednotFoundOnItemhelper instead of duplicating the predicate inline — behavior-identical. This is the diff's only provisioning-path touch outside the schedule seam.Why
Deletewas that next call site.pkg/connector/errors_test.goandpkg/connector/schedule_test.go(new)Where:
TestNotFoundOnItem~L45;TestScheduleResourceType_Grants~L83;both reuse the existing
newMockServerhttptest patternWhat changed
a non-404 HTTP status, isolating the SDK's code arm) are skippable; 403,
429, 500, a non-APIError, and nil are not.
Grantstest through a real SDK client against a mock server:404 on the on-call endpoint returns the member grants with a nil error and
no on-call grant; 500 surfaces as
Unavailable, 401 asUnauthenticated,403 as
PermissionDenied.line and no ERROR/WARN — the log-level contract is pinned, not just
claimed.
Why
what these tests exist to catch if the guard is ever widened by mistake.
How far this is verified
scripts/validate-changes.sh(build + vet + test of./pkg/connector,the packages this diff touches): exit 0.
scripts/check-kind-rules.sh: 0 violations, 0 hints.the round-2 fixes were test-only hardening (log-level assertion, code-2100
isolation, trailing newline), and commit 80b8ec46 consolidates
user.Delete'sinline 404 guard onto the shared
notFoundOnItemhelper (behavior-identical).no sync was exercised by the smoke gate — the change is unproven against
a live or mocked upstream by that gate alone. The batch's connector-eval
tool separately replayed a full sync against a mock of the PagerDuty API
built from its official docs: object-for-object identical to
mainon thesame recording (0 resources/entitlements/grants lost or gained; see
connector-eval below).
80b8ec46(pr-review, verify/lint). The repository'sreview bot accepted the change after one fix pass: it flagged that the
SDK's
NotFound()predicate treats API error code 2100 as absence on anyHTTP status — wider than a bare "404 = absence" claim — so the doc comment
was corrected to state the wider semantics precisely (the guard code is
byte-identical; the bot's own suggested resolution, and the repo's own
idiom elsewhere in the package).
criteria WORKS. Highlights: a real sync of the built binary against a mock
that force-404s the on-call listing completes exit 0, and a grant diff
against the base recording shows the ONLY delta is the vanished schedule's
2 on-call grants (all member grants intact); forcing a 500 on the same seam
still fails the sync. The tester shared this VM's toolchain (clean checkout,
not a clean VM), and the live PagerDuty API was NOT exercised (no
credentials in the environment — all probes ran against the
vendor-documented mock).
answered and resolved on the PR. Round 1: the new
notFoundOnItemhelperduplicated the identical inline predicate in
user.Delete— fixed byconsolidating
user.Deleteonto the helper (commit80b8ec46,behavior-identical; the diff's only provisioning-path touch). Round 2: the
PR body did not document that provisioning-path touch — fixed by updating
this description (no code change). A reader who had never seen this batch
read it cold and raised two things; both were fixed and resolved.
connector-eval (advisory): regression — "regression on the matched
requests; 1 requests not in the recording (re-ran with --allow-unmatched)".
Investigated before ranking: the one unmatched request is the on-call listing
itself (
GET /schedules/{id}/users), whosesince/untilparameters arederived from the clock and change between runs, so the recording cannot
exact-match it — the base (
main) run shows the identical limitation, and theobject diff is 0/0/0 with no new static findings. Connector-eval is advisory
in this pipeline; the verdict is a recording artifact shared by every
candidate, not a behavior change.
What to look at hardest
Grants— the whole change lives in one branch;check that the comment's claim (single-object GET, so 404 = this schedule)
still holds if the call ever moves to a multi-schedule endpoint.
team.go's per-team member listing has the same theoreticalshape and still fails the sync on a mid-sync team deletion. That is
deliberate — the ticket scopes the fix to the reported schedule seam, and
the new
notFoundOnItemhelper makes that follow-up a two-line change.grants still emit for the schedule that disappeared; the next full sync's
list phase removes the schedule and its grants. One self-healing cycle of
lag, per the ticket's requirement that the sync not fail.
Release Notes
baton-pagerdutyno longer fails a sync when a PagerDuty schedule is deleted(or otherwise stops resolving) mid-sync: the connector now skips that
schedule's on-call grants, logs at debug, and completes the sync instead of
erroring with 404 "Schedule Not Found" and requiring a support-dashboard
re-run.