Skip to content

Remove broken client.branch.diff_data() - #1229

Open
saltas888 wants to merge 7 commits into
infrahub-developfrom
dsa-06082026-remove-branch-diff-data
Open

Remove broken client.branch.diff_data()#1229
saltas888 wants to merge 7 commits into
infrahub-developfrom
dsa-06082026-remove-branch-diff-data

Conversation

@saltas888

@saltas888 saltas888 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Why

client.branch.diff_data() has never worked: it calls GET /api/diff/data, an endpoint removed from Infrahub in opsmill/infrahub#4865, and its URL builder is also missing the ? separator, so every call returns a 404 (#325).

opsmill/infrahub#8594 tried to fix this by adding the missing REST endpoint back, but as @ogenstad pointed out there, the SDK should use existing queries/mutations rather than get a server endpoint of its own, and the broken method should be removed or refactored instead.

The SDK already has GraphQL-based diff methods (get_diff_tree(), get_diff_summary(), both backed by the DiffTree query), but they only fetched summary counts, while the original diff_data() returned the data-level diff including previous/new values. So this PR removes the broken method and extends get_diff_tree() to cover what diff_data() was meant to provide.

Closes #325

What changed

  • Removed diff_data() from InfrahubBranchManager and InfrahubBranchManagerSync
  • Removed InfraHubBranchManagerBase, whose only content was the diff_data URL builder (generate_diff_data_url)
  • Added include_properties to client.get_diff_tree() (async and sync), when True the diff tree includes value-level details per change: previous/new value per attribute property, and peer id/label per relationship element
  • Rewrote the "Generating a diff for a branch" section of the branches guide to use client.get_diff_tree() / client.get_diff_summary()
  • Changelog entries (removed + added)

Since the method has returned a 404 for as long as the endpoint has been absent, no working code can be calling it, removal without a deprecation cycle should be safe.

How to review

  1. infrahub_sdk/branch.py, pure deletion
  2. infrahub_sdk/diff.py, the include_properties extension of the query builder and response parsing
  3. tests/integration/test_diff_tree.py, end-to-end coverage against a live Infrahub (attribute value change + relationship peer change)
  4. docs/docs/python-sdk/guides/branches.mdx, the replacement guidance

How to test

uv run pytest tests/unit/sdk/test_diff_summary.py
uv run pytest tests/integration/test_diff_tree.py

Impact & rollout

  • Backward compatibility: removes a public method that could not be used successfully; callers migrating should switch to get_diff_tree() / get_diff_summary() (note there is no branch_only equivalent, DiffTree always compares the branch against its base). include_properties defaults to False, existing get_diff_tree() callers are unaffected.
  • Config/env changes: none

Checklist

  • Tests added/updated
  • Changelog entry added
  • External docs updated
  • Internal .md docs updated (n/a)

@saltas888
saltas888 requested a review from a team as a code owner August 6, 2026 11:32
@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Aug 6, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: e14dec2
Status: ✅  Deploy successful!
Preview URL: https://26132e92.infrahub-sdk-python.pages.dev
Branch Preview URL: https://dsa-06082026-remove-branch-d.infrahub-sdk-python.pages.dev

View logs

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/diff.py 97.67% 0 Missing and 1 partial ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop    #1229      +/-   ##
====================================================
+ Coverage             84.00%   84.13%   +0.12%     
====================================================
  Files                   147      147              
  Lines                 13063    13078      +15     
  Branches               1932     1936       +4     
====================================================
+ Hits                  10974    11003      +29     
+ Misses                 1522     1507      -15     
- Partials                567      568       +1     
Flag Coverage Δ
integration-tests 39.28% <50.00%> (+0.32%) ⬆️
python-3.10 56.95% <56.25%> (+0.11%) ⬆️
python-3.11 56.95% <56.25%> (+0.10%) ⬆️
python-3.12 56.94% <56.25%> (+0.10%) ⬆️
python-3.13 56.95% <56.25%> (+0.11%) ⬆️
python-3.14 56.94% <56.25%> (+0.08%) ⬆️
python-filler-3.12 23.64% <41.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/branch.py 82.11% <100.00%> (+7.63%) ⬆️
infrahub_sdk/client.py 79.76% <100.00%> (ø)
infrahub_sdk/diff.py 96.77% <97.67%> (+0.34%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread infrahub_sdk/diff.py Outdated
saltas888 and others added 6 commits August 7, 2026 12:01
The method targeted GET /api/diff/data, a REST endpoint that does not
exist in Infrahub, so every call returned a 404 (and the URL builder
was also missing the ? separator). Instead of adding a server endpoint
for it, drop the method and point users at the existing GraphQL-based
client.get_diff_tree() / client.get_diff_summary().

Also removes InfraHubBranchManagerBase, whose only content was the
diff_data URL builder, and updates the branches guide accordingly.

Closes #325

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The DiffTree GraphQL query exposes previous/new values per property but
the SDK only fetched summary counts, so removing diff_data() would have
left no way to retrieve the data-level diff it was meant to provide.
With include_properties=True the diff tree now includes value-level
details per attribute property and peer id/label per relationship
element.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The query already fetched them but the parser dropped them for ONE
relationships, leaving the IS_RELATED property as the only way to
identify the changed peer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Extract the element-to-peer conversion into a helper shared by both
cardinality branches, and stop silently dropping trailing elements when
a cardinality-one relationship unexpectedly carries several: they now
come back as peers, same shape as cardinality-many.

The include_properties addition is folded into the removal changelog
entry since it exists as the diff_data() replacement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…inality-one flattening

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@saltas888
saltas888 force-pushed the dsa-06082026-remove-branch-diff-data branch from a9e6022 to 6550507 Compare August 7, 2026 09:06
@saltas888
saltas888 changed the base branch from stable to infrahub-develop August 7, 2026 09:06
…ity-one flattening

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Method client.branch.diff_data() returns a 404

1 participant