-
Notifications
You must be signed in to change notification settings - Fork 6
Fix branch creation with sync client #527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a changelog entry documenting a fix related to branch creation with the sync client when wait_until_completion=False. In infrahub_sdk/branch.py, BranchCreate now selects between two GraphQL queries based on background_execution. When background_execution is true, the create methods return the task id string; otherwise they return BranchData from the object. This applies to both async and sync branch managers. No public signatures changed. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## stable #527 +/- ##
==========================================
- Coverage 75.98% 75.77% -0.21%
==========================================
Files 100 100
Lines 9369 8860 -509
Branches 1932 1738 -194
==========================================
- Hits 7119 6714 -405
+ Misses 1727 1670 -57
+ Partials 523 476 -47
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Deploying infrahub-sdk-python with
|
| Latest commit: |
b2fbb8f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bb53c49c.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://gma-20250904-ihs127.infrahub-sdk-python.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
infrahub_sdk/branch.py (4)
84-85: Fix deprecation warning always firing; defaultbackground_executionshould beNone.With
background_execution: bool | None = False,background_execution is not Noneis always true (even when the caller didn’t pass it), spamming aDeprecationWarning. Default toNoneso warnings are only emitted when the arg is explicitly provided.@@ - wait_until_completion: Literal[True] = True, - background_execution: bool | None = False, + wait_until_completion: Literal[True] = True, + background_execution: bool | None = None, @@ - wait_until_completion: Literal[False] = False, - background_execution: bool | None = False, + wait_until_completion: Literal[False] = False, + background_execution: bool | None = None, @@ - wait_until_completion: bool = True, - background_execution: bool | None = False, + wait_until_completion: bool = True, + background_execution: bool | None = None, @@ - wait_until_completion: Literal[True] = True, - background_execution: bool | None = False, + wait_until_completion: Literal[True] = True, + background_execution: bool | None = None, @@ - wait_until_completion: Literal[False] = False, - background_execution: bool | None = False, + wait_until_completion: Literal[False] = False, + background_execution: bool | None = None, @@ - wait_until_completion: bool = True, - background_execution: bool | None = False, + wait_until_completion: bool = True, + background_execution: bool | None = None,Also applies to: 94-95, 103-104, 255-257, 265-267, 275-276
60-71: Bug: missing '?' in diff_data URL construction.
return url + urlencode(url_params)yields an invalid path (no query separator). Add '?'.- return url + urlencode(url_params) + return url + "?" + urlencode(url_params)
143-152: Alignrebasereturn annotation with actual bool return
- In infrahub_sdk/branch.py, update both
async def rebase(line 143) and its sync counterpart (line 343) from-> BranchDatato-> bool.- Optionally restrict the GraphQL payload to only fetch the
okfield.- Update the Python SDK examples (docs/docs/python-sdk/examples/branch_rebase.py and branch_rebase_sync.py) to reflect the boolean return.
153-172: Changevalidatereturn annotations tobool
Both the async (around line 153) and sync (around line 353)validate(self, branch_name: str) -> BranchDatamethods returnresponse["BranchValidate"]["ok"](abool), not aBranchData. Update their return type to-> bool.
🧹 Nitpick comments (3)
infrahub_sdk/branch.py (2)
295-303: LGTM: correct GraphQL selection and return shape for sync create when running in background.Selecting
MUTATION_QUERY_TASKand returningtask.idresolves the previous mismatch and aligns with the async path. Consider adding/adjusting tests for bothwait_until_completion=TrueandFalseon the sync client.
105-111: Point deprecation to caller: bumpstacklevelto 2.Improves signal by pointing the warning at the user’s callsite.
- stacklevel=1, + stacklevel=2,Also applies to: 277-283
changelog/374.fixed.md (1)
1-1: Nit: end with a period for consistency.-Fix branch creation with the sync client while setting `wait_until_completion=False` +Fix branch creation with the sync client while setting `wait_until_completion=False`.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
changelog/374.fixed.md(1 hunks)infrahub_sdk/branch.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method
Files:
infrahub_sdk/branch.py
🧬 Code graph analysis (1)
infrahub_sdk/branch.py (2)
infrahub_sdk/graphql.py (3)
Mutation(170-201)render(158-167)render(178-201)infrahub_sdk/client.py (2)
execute_graphql(876-956)execute_graphql(1619-1699)
This change addresses an issue when trying to create a branch using the sync client and by setting
wait_until_completion=False. The mutation was able to read and return the task ID properly.Summary by CodeRabbit
Bug Fixes
Documentation