Skip to content

IHS-114: Fix diff url#865

Open
solababs wants to merge 3 commits intoinfrahub-developfrom
sb-12032026-fix-diff-url-ihs-114
Open

IHS-114: Fix diff url#865
solababs wants to merge 3 commits intoinfrahub-developfrom
sb-12032026-fix-diff-url-ihs-114

Conversation

@solababs
Copy link
Contributor

@solababs solababs commented Mar 12, 2026

Why

The SDK's URL builder was missing a ? separator before query parameters, producing malformed URLs like /api/diff/databranch=test-branch&branch_only=true.

Closes #325

What changed

  • Fixed SDK URL bugInfraHubBranchManagerBase.generate_diff_data_url was concatenating query params without a ? separator; now correctly produces /api/diff/data?branch=...&branch_only=....

How to review

  1. python_sdk/infrahub_sdk/branch.py:82 — the one-character URL fix (+ "?" +)

Impact & rollout

  • Backward compatibility: additive only
  • Performance: no impact on existing endpoints
  • Config/env changes: none
  • Deployment notes: safe to deploy

Checklist

  • Tests added/updated
  • Changelog entry added (uv run towncrier create ...)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed query parameter formatting in diff data URLs to ensure proper query string construction.

@solababs solababs requested a review from a team as a code owner March 12, 2026 15:11
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Warning

Rate limit exceeded

@solababs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2be2e335-39eb-441c-bef8-12072c10c00f

📥 Commits

Reviewing files that changed from the base of the PR and between 60d1c4d and ed3b78b.

📒 Files selected for processing (1)
  • changelog/325.fixed.md

Walkthrough

A fix was made to the URL construction logic in the diff data URL generation functionality. Previously, query parameters were concatenated directly to the base URL without properly including the query string separator. The change adds a "?" character before the encoded parameters to ensure correct query string formatting. This modification was documented with a corresponding changelog entry.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'IHS-114: Fix diff url' directly relates to the main change—fixing the missing '?' separator in the diff URL builder.
Description check ✅ Passed The PR description covers the why (malformed URL issue), what changed (the specific fix with line reference), how to review, and impact/rollout details, with a filled checklist.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan for PR comments
  • Generate coding plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
infrahub_sdk/branch.py (1)

82-82: Add a regression test for the URL builder.

This fix looks correct, but there’s no matching test in this diff. A small unit test around generate_diff_data_url() would lock in the ? separator and cover the optional time_from / time_to branches so this malformed URL shape doesn’t regress again.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@infrahub_sdk/branch.py` at line 82, Add a unit test for
generate_diff_data_url that asserts the returned URL always contains a single
'?' before the query string and correctly includes optional query params when
time_from and/or time_to are provided; specifically write tests that call
generate_diff_data_url() with (a) only required params to ensure the URL
contains "?" then the encoded params, (b) with time_from set, (c) with time_to
set, and (d) with both set, asserting the encoded values appear and no extra '?'
or malformed separators occur so the current behavior in the function (return
url + "?" + urlencode(url_params)) is locked in.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@infrahub_sdk/branch.py`:
- Line 82: Add a unit test for generate_diff_data_url that asserts the returned
URL always contains a single '?' before the query string and correctly includes
optional query params when time_from and/or time_to are provided; specifically
write tests that call generate_diff_data_url() with (a) only required params to
ensure the URL contains "?" then the encoded params, (b) with time_from set, (c)
with time_to set, and (d) with both set, asserting the encoded values appear and
no extra '?' or malformed separators occur so the current behavior in the
function (return url + "?" + urlencode(url_params)) is locked in.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6dc20e21-9d14-440d-b8ad-74cd4275d045

📥 Commits

Reviewing files that changed from the base of the PR and between f737549 and 60d1c4d.

📒 Files selected for processing (2)
  • changelog/325.fixed.md
  • infrahub_sdk/branch.py

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

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

Files with missing lines Patch % Lines
infrahub_sdk/branch.py 0.00% 1 Missing ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #865      +/-   ##
====================================================
+ Coverage             80.64%   80.66%   +0.01%     
====================================================
  Files                   118      118              
  Lines                 10246    10246              
  Branches               1534     1534              
====================================================
+ Hits                   8263     8265       +2     
+ Misses                 1455     1454       -1     
+ Partials                528      527       -1     
Flag Coverage Δ
integration-tests 40.35% <0.00%> (ø)
python-3.10 51.82% <0.00%> (ø)
python-3.11 51.82% <0.00%> (ø)
python-3.12 51.82% <0.00%> (ø)
python-3.13 51.84% <0.00%> (+0.01%) ⬆️
python-3.14 53.52% <0.00%> (ø)
python-filler-3.12 24.03% <0.00%> (ø)

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

Files with missing lines Coverage Δ
infrahub_sdk/branch.py 68.53% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant