Skip to content

Conversation

@btipling
Copy link

@btipling btipling commented Jan 22, 2026

Wrap 404 errors from OpsGenie API with codes.NotFound so baton-sdk can handle these as warnings instead of errors. This prevents sync failures when a schedule is deleted or renamed in OpsGenie.

Fixes: CX-512

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of third-party on-call API "Not Found" responses: these are now surfaced as clear "Not Found" errors with descriptive messaging instead of a generic failure.
    • Improves diagnostics and user feedback when requested schedules or resources are missing; other error behavior is unchanged.
    • No public interfaces were modified.

✏️ Tip: You can customize this high-level summary in your review settings.

Wrap 404 errors from OpsGenie API with codes.NotFound so baton-sdk
can handle these as warnings instead of errors. This prevents sync
failures when a schedule is deleted or renamed in OpsGenie.

Fixes: CX-512
@btipling btipling requested a review from a team January 22, 2026 23:45
@linear
Copy link

linear bot commented Jan 22, 2026

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

Adds handling for 404 Not Found responses from the OpsGenie GetOnCalls call in the schedule grants flow, mapping such cases to a gRPC NotFound status with a descriptive message instead of a generic error.

Changes

Cohort / File(s) Summary
OpsGenie 404 Error Handling
pkg/connector/schedule.go
Detects OpsGenie ApiError with HTTP 404 and returns a gRPC NotFound status with a descriptive message; retains prior behavior for non-404 errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nudged a 404 from the briar,
Turned its howl to a quiet choir,
gRPC sings what once was hid,
Now not-found hops where code once slid. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: handle 404 errors on list grants for schedules' directly and clearly describes the main change: adding 404 error handling to the schedule grants flow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/connector/schedule.go`:
- Around line 206-210: The current direct type assertion on err to
*ogClient.ApiError in the schedule handling code can miss wrapped errors; import
the "errors" package and replace the assertion with errors.As to unwrap and test
for *ogClient.ApiError (e.g., declare a var apiErr *ogClient.ApiError and call
errors.As(err, &apiErr) ), and if true and apiErr.StatusCode ==
http.StatusNotFound return the same status.Error(codes.NotFound,
fmt.Sprintf(...)) so wrapped ApiError instances are correctly detected; update
imports to include "errors".

Replace direct type assertion with errors.As to correctly detect
wrapped *ogClient.ApiError instances when checking for 404 errors.
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.

4 participants