Skip to content

fix(synthetics): tolerate null in downtime list - #725

Open
platinummonkey wants to merge 2 commits into
mainfrom
dd/fix/synthetics-downtime-null-arrays-722
Open

fix(synthetics): tolerate null in downtime list#725
platinummonkey wants to merge 2 commits into
mainfrom
dd/fix/synthetics-downtime-null-arrays-722

Conversation

@platinummonkey

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes pup synthetics downtime list failing on a successful API response with:

Error: failed to list synthetics downtimes: Serde(Error("invalid type: null, expected a sequence", ...))

The typed datadog-api-client V2 model deserializes downtime responses strictly, so a null where it expects a JSON array aborts the whole listing. This change adds a targeted fallback in downtime_list (src/commands/synthetics.rs):

  • Keep the existing typed list_synthetics_downtimes call for the happy path (unchanged output, zero regression risk).
  • Only when it fails with a datadog::Error::Serde(_) — the exact failure mode in synthetics downtime list fails to deserialize response (invalid type: null, expected a sequence) #722, which per the reporter occurs solely on 2xx responses — re-fetch via the existing null-tolerant raw_client::raw_get against /api/v2/synthetics/downtimes and emit the raw JSON:API body.
  • The --filter-test-ids / --filter-active filters are forwarded on the fallback path (filter[test_ids] / filter[active], matching the repo's existing V2 filter convention in apm.rs).
  • Genuine HTTP errors (e.g. 403) keep their original error handling.

Motivation

synthetics downtime list is completely unusable against any org whose downtime payload contains a null array field: the strict typed model turns an otherwise-valid 2xx response into a hard error. Reusing the project's existing raw_client (rather than patching the pinned SDK crate) restores the command while leaving healthy responses and real error responses untouched.

Additional Notes

  • Reuses raw_client::raw_get (same pattern as apm.rs / change_stories.rs) instead of introducing new HTTP plumbing; no new imports or dependencies.
  • The fallback is scoped strictly to the Serde deserialization variant, so it can never mask legitimate API errors.
  • Sandbox limitation: the pinned datadog-api-client git dependency could not be fetched through the environment's proxy allowlist, so cargo build/cargo test could not be run here. Verified with cargo fmt --check (passes) plus manual review. CI will run the full build/clippy/test matrix.

Testing

Added two unit tests in the existing mockito-based harness:

  • test_synthetics_downtime_list_falls_back_on_deserialize_error — a 2xx body the typed model can't deserialize now yields output via the raw fallback instead of an error.
  • test_synthetics_downtime_list_fallback_with_filters — the fallback path with both filters set.

Existing tests remain valid: test_synthetics_downtime_list (healthy {"data":[]} → typed path) and test_synthetics_downtime_list_error (403 → error) are unaffected.

Checklist

  • The code change follows the project conventions (see CONTRIBUTING.md)
  • Tests have been added/updated (if applicable)
  • Documentation has been updated (if applicable) — not applicable (no user-facing behavior/flags changed)
  • All CI checks pass — could not be run in the sandbox; pending CI
  • Code coverage is maintained or improved

Related Issues

Closes #722


PR by Bits - View session in Datadog

Comment @DataDog to request changes

…tion fails

The typed V2 client rejects successful responses containing null where an
array is expected (issue #722). Fall back to the null-tolerant raw JSON:API
body via raw_client::raw_get only on the Serde error path, preserving the
existing behavior for healthy responses and genuine HTTP errors.

Co-authored-by: platinummonkey <cody.lee@datadoghq.com>
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

View session in Datadog

Bits Code status: ✅ Done

CI Auto-fix: Passed | Disable

Comment @DataDog to request changes

@platinummonkey
platinummonkey requested a review from a team as a code owner August 13, 2026 19:00
@datadog-datadog-prod-us1-2

Copy link
Copy Markdown

I can only run on private repositories.

@Katomoto Katomoto left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Logic looks correct. One suggestion: the early return on line prevents the cleanup function from running — worth adding a finally block.

@platinummonkey

Copy link
Copy Markdown
Collaborator Author

Logic looks correct. One suggestion: the early return on line prevents the cleanup function from running — worth adding a finally block.

@Katomoto will do a bit of follow up work here since it's common with other tests right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

synthetics downtime list fails to deserialize response (invalid type: null, expected a sequence)

3 participants