Skip to content

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

Merged
saltas888 merged 8 commits into
infrahub-developfrom
dsa-06082026-remove-branch-diff-data
Aug 11, 2026
Merged

Remove broken client.branch.diff_data()#1229
saltas888 merged 8 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 instead. Since the method has returned a 404 for as long as the endpoint has been absent, nobody can be using it, so it is deleted without a replacement.

For branch diffs the SDK already has the GraphQL-based get_diff_tree() and get_diff_summary(), both backed by the DiffTree query.

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)
  • Rewrote the "Generating a diff for a branch" section of the branches guide to point at client.get_diff_tree() / client.get_diff_summary()
  • Changelog entry (removed)

An earlier iteration also extended get_diff_tree() with an include_properties option to preserve the value-level diff that diff_data() was meant to return, we agreed the broken functionality is unused so a plain removal is preferable. Those commits are reverted on the branch, the net diff is the removal only.

How to review

  1. infrahub_sdk/branch.py, pure deletion
  2. docs/docs/python-sdk/guides/branches.mdx, the replacement guidance

How to test

uv run pytest tests/unit/sdk/test_diff_summary.py tests/unit/sdk/test_branch.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).
  • Config/env changes: none

Checklist

  • 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: 2859aa0
Status: ✅  Deploy successful!
Preview URL: https://d4f41933.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

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop    #1229      +/-   ##
====================================================
+ Coverage             84.00%   84.09%   +0.08%     
====================================================
  Files                   147      147              
  Lines                 13063    13041      -22     
  Branches               1932     1930       -2     
====================================================
- Hits                  10974    10967       -7     
+ Misses                 1522     1507      -15     
  Partials                567      567              
Flag Coverage Δ
integration-tests 39.03% <0.00%> (+0.07%) ⬆️
python-3.10 56.93% <0.00%> (+0.09%) ⬆️
python-3.11 56.95% <0.00%> (+0.09%) ⬆️
python-3.12 56.93% <0.00%> (+0.09%) ⬆️
python-3.13 56.93% <0.00%> (+0.09%) ⬆️
python-3.14 56.94% <0.00%> (+0.09%) ⬆️
python-filler-3.12 23.60% <100.00%> (-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%) ⬆️
🚀 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>
…data removal

Nobody uses the value-level diff data, so the broken method is deleted
without a replacement API.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@saltas888

Copy link
Copy Markdown
Contributor Author

After the approval, I discussed with @ogenstad that we would much rather remove a broken functionality and assume nobody uses it.

@saltas888
saltas888 merged commit 46e16db into infrahub-develop Aug 11, 2026
21 checks passed
@saltas888
saltas888 deleted the dsa-06082026-remove-branch-diff-data branch August 11, 2026 09:39
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

2 participants