Skip to content

feat(id-file): support dashboards in import and sync state loading - #686

Merged
michael-richey merged 2 commits into
mainfrom
michael.richey/add-dashboards-id-file-support
Sep 1, 2026
Merged

feat(id-file): support dashboards in import and sync state loading#686
michael-richey merged 2 commits into
mainfrom
michael.richey/add-dashboards-id-file-support

Conversation

@michael-richey

@michael-richey michael-richey commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

What

Adds dashboards to the import and state-load --id-file allowlists:

  • import --id-file can fetch only the selected dashboard IDs.
  • sync --minimize-reads --id-file can load state only for those dashboard IDs because dashboard state keys are ID-derivable.

Why

Lets callers split a large dashboard set into multiple sync-cli subprocesses instead of one monolithic import that can time out before finishing. The same ID payload can scope state reads during sync, avoiding a full type load when only those dashboards are being processed.

Verification

Dashboards.import_resource(_id=...) performs a real GET /api/v1/dashboard/{id} for the full body because widgets are omitted by the LIST endpoint. It short-circuits when the caller supplies a body that already contains widgets, so the get_resources_by_ids -> import_resource(_id) -> queue-handler _import_resource(resource=body) path performs exactly one GET per dashboard.

Dashboard state is stored as dashboards.<id>.json, so State.get_by_ids can construct the source and destination keys directly for sync --minimize-reads.

  • New: tests/unit/test_dashboards_id_file.py pins both allowlist entries, the per-ID GET, the prefetched-body short-circuit, 403→SkipResource, and 5xx propagation.
  • Updated: three existing tests that used dashboards as their unsupported-type example now use notebooks to preserve their intent.
70 passed, 0 failed  (dashboard / id-file focused suites)

@michael-richey
michael-richey requested a balanced review from Copilot September 1, 2026 19:09
@michael-richey
michael-richey marked this pull request as ready for review September 1, 2026 19:10
@michael-richey
michael-richey requested a review from a team as a code owner September 1, 2026 19:10
@michael-richey
michael-richey force-pushed the michael.richey/add-dashboards-id-file-support branch from 919c8ba to 01cb5df Compare September 1, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enables dashboard-specific imports through --id-file.

Changes:

  • Adds dashboards to the import allowlist.
  • Adds dashboard ID-fetch and error-handling tests.
  • Updates unsupported-type tests to use notebooks.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
datadog_sync/utils/configuration.py Adds dashboard ID-file support.
tests/unit/test_dashboards_id_file.py Tests dashboard ID imports.
tests/unit/test_get_resources_by_ids_experiment.py Updates unsupported-type coverage.
tests/unit/test_id_file_state_load_scoping.py Updates parser rejection coverage.
tests/unit/test_id_file_subprocess_experiment.py Updates subprocess rejection coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread datadog_sync/utils/configuration.py
Comment thread tests/unit/test_dashboards_id_file.py Outdated
Add 'dashboards' to _ID_FILE_IMPORT_SUPPORTED_TYPES so the import command
accepts --id-file payloads selecting specific dashboards by ID. This lets
callers split a large dashboards set into multiple sync-cli subprocesses
(importing a subset of IDs per invocation) instead of one monolithic run
that can time out before finishing on orgs with tens of thousands of
dashboards.

Dashboards.import_resource(_id=...) already performs a real GET to
/api/v1/dashboard/{id} for the full body (widgets are omitted by the LIST
endpoint) and short-circuits when the caller passes a body already carrying
widgets, so the id-file path's get_resources_by_ids -> import_resource(_id)
-> queue-handler _import_resource(resource=body) sequence does exactly one
GET per dashboard with no double-fetch. Verified via
tests/unit/test_dashboards_id_file.py.

Three existing tests used 'dashboards' as their example of an *unsupported*
type in --id-file; updated them to 'notebooks' (genuinely unsupported) to
preserve their intent.
@michael-richey
michael-richey force-pushed the michael.richey/add-dashboards-id-file-support branch from 01cb5df to 5d78122 Compare September 1, 2026 19:15
@michael-richey michael-richey changed the title feat(import): allow dashboards in --id-file feat(id-file): support dashboards in import and sync state loading Sep 1, 2026
@michael-richey
michael-richey merged commit 942dcab into main Sep 1, 2026
11 checks passed
@michael-richey
michael-richey deleted the michael.richey/add-dashboards-id-file-support branch September 1, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants