Skip to content

Conversation

@gmazoyer
Copy link
Contributor

@gmazoyer gmazoyer commented Sep 4, 2025

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

    • Resolved branch creation issues when using the sync client with wait_until_completion set to False.
    • For background executions, branch creation now returns a task ID, improving clarity and reliability.
    • Aligned async and sync clients for consistent behavior in background branch creation.
    • Non-background branch creation continues to return full branch details as before.
  • Documentation

    • Added a changelog entry describing the branch creation fix for the sync client.

@coderabbitai
Copy link

coderabbitai bot commented Sep 4, 2025

Walkthrough

Adds 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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gma-20250904-ihs127

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/branch.py 0.00% 3 Missing ⚠️
@@            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     
Flag Coverage Δ
integration-tests 34.74% <0.00%> (+0.07%) ⬆️
python-3.10 48.27% <0.00%> (-0.53%) ⬇️
python-3.11 48.29% <0.00%> (-0.51%) ⬇️
python-3.12 48.25% <0.00%> (-0.53%) ⬇️
python-3.13 48.27% <0.00%> (-0.51%) ⬇️
python-3.9 46.96% <0.00%> (-0.55%) ⬇️
python-filler-3.12 25.05% <0.00%> (-0.18%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/branch.py 54.54% <0.00%> (-0.39%) ⬇️

... 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.

@cloudflare-workers-and-pages
Copy link

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

@gmazoyer gmazoyer marked this pull request as ready for review September 4, 2025 08:28
@gmazoyer gmazoyer requested a review from a team September 4, 2025 08:28
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.

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; default background_execution should be None.

With background_execution: bool | None = False, background_execution is not None is always true (even when the caller didn’t pass it), spamming a DeprecationWarning. Default to None so 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: Align rebase return annotation with actual bool return

  • In infrahub_sdk/branch.py, update both async def rebase (line 143) and its sync counterpart (line 343) from -> BranchData to -> bool.
  • Optionally restrict the GraphQL payload to only fetch the ok field.
  • 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: Change validate return annotations to bool
Both the async (around line 153) and sync (around line 353) validate(self, branch_name: str) -> BranchData methods return response["BranchValidate"]["ok"] (a bool), not a BranchData. 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_TASK and returning task.id resolves the previous mismatch and aligns with the async path. Consider adding/adjusting tests for both wait_until_completion=True and False on the sync client.


105-111: Point deprecation to caller: bump stacklevel to 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 266fecc and b2fbb8f.

📒 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)

@gmazoyer gmazoyer merged commit 6638c90 into stable Sep 4, 2025
20 checks passed
@gmazoyer gmazoyer deleted the gma-20250904-ihs127 branch September 4, 2025 11:50
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.

bug: Sync branch creation doesn't correctly handle wait_until_completion

2 participants