fix(downtime_schedules): reconcile destination conflicts - #656
Merged
michael-richey merged 1 commit intoAug 3, 2026
Merged
Conversation
Recover an unambiguous duplicate create by fetching and persisting the existing destination downtime. Reject ambiguous duplicate responses so unmanaged resources are not silently accepted. When an update reports that its mapped downtime is gone, recreate it and replace the stale mapping. Other 404 responses continue through normal failure accounting. Keep delete 404 handling idempotent. Add regression coverage for state replacement, duplicate reconciliation, ambiguous conflicts, unrelated 404 responses, and sibling progress.
michael-richey
force-pushed
the
michael.richey/downtime-schedules-conflict-skip
branch
from
August 3, 2026 18:15
76b02d1 to
82d8d59
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves downtime_schedules sync robustness by handling deterministic destination-side conflict and “gone” conditions in a way that avoids leaving stale/unmanaged destination mappings, while still propagating unrelated failures for normal retry/accounting.
Changes:
- Reconcile create-time duplicate (
400) by parsing the structured error body, fetching the single unambiguous existing downtime, and persisting its mapping. - Handle update-time not-found (
404with “Downtime not found”) by recreating the downtime and replacing the stale destination mapping; propagate unrelated404s. - Expose HTTP response bodies on
CustomClientHTTPErrorto enable structured error parsing, and add focused unit tests for the new behaviors (including delete404idempotency).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
datadog_sync/model/downtime_schedules.py |
Adds deterministic conflict/not-found handling for create/update/delete and factors create-schedule normalization into a helper. |
datadog_sync/utils/resource_utils.py |
Extends CustomClientHTTPError to retain the response body for downstream error inspection. |
tests/unit/test_downtime_schedules_conflict_skip.py |
Adds unit coverage for duplicate-create reconciliation, update-not-found recreation, and delete 404 idempotency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
michael-richey
marked this pull request as ready for review
August 3, 2026 18:51
heyronhay
approved these changes
Aug 3, 2026
michael-richey
deleted the
michael.richey/downtime-schedules-conflict-skip
branch
August 3, 2026 20:04
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
Handle deterministic downtime destination conflicts without leaving stale or unmanaged state.
What this PR changes
400, parse the structured API error. If it identifies exactly one existing downtime, fetch that resource and persist its source-to-destination mapping.404with the specificDowntime not founderror, recreate the downtime and replace the stale destination mapping with the new response.404responses.404as an idempotent success.Test plan
404and other4xx/5xxresponses propagate.404remains idempotent.