-
Notifications
You must be signed in to change notification settings - Fork 6
Respect default branch for client.query_gql_query() #518
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
WalkthroughThe change updates both async and sync GraphQL query builders in Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
✨ 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 (
|
Deploying infrahub-sdk-python with
|
| Latest commit: |
4dde424
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://80159827.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pog-query-branch-ihs-89.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## stable #518 +/- ##
==========================================
+ Coverage 75.76% 75.77% +0.01%
==========================================
Files 100 100
Lines 8858 8856 -2
Branches 1737 1735 -2
==========================================
Hits 6711 6711
+ Misses 1670 1669 -1
+ Partials 477 476 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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: 1
📜 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 (1)
infrahub_sdk/client.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/client.py
infrahub_sdk/client.py
📄 CodeRabbit inference engine (CLAUDE.md)
infrahub_sdk/client.py: Use HTTPX for transport with proxy support (single proxy or HTTP/HTTPS mounts)
Support authentication via API tokens or JWT with automatic refresh
Files:
infrahub_sdk/client.py
🧬 Code graph analysis (1)
infrahub_sdk/client.py (2)
infrahub_sdk/operation.py (1)
branch_name(33-44)infrahub_sdk/checks.py (1)
branch_name(134-144)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: unit-tests (3.10)
- GitHub Check: unit-tests (3.12)
- GitHub Check: unit-tests (3.13)
- GitHub Check: integration-tests-latest-infrahub
🔇 Additional comments (1)
infrahub_sdk/client.py (1)
1106-1107: Don’t clobber caller-supplied params['branch']; only default when missing.Apply:
- url_params["branch"] = branch_name or self.default_branch + if branch_name: + url_params["branch"] = branch_name + elif "branch" not in url_params and self.default_branch: + url_params["branch"] = self.default_branchVerify no callers rely on passing
branchviaparams.
| url_params["branch"] = branch_name or self.default_branch | ||
|
|
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.
💡 Verification agent
🧩 Analysis chain
Mirror the non-breaking precedence in sync path.
Same concern and fix as async; keep params['branch'] if provided, else fall back to default.
- url_params["branch"] = branch_name or self.default_branch
+ if branch_name:
+ url_params["branch"] = branch_name
+ elif "branch" not in url_params and self.default_branch:
+ url_params["branch"] = self.default_branchOptional follow-up: extract this small precedence block into a BaseClient helper to DRY both call sites.
🏁 Script executed:
#!/bin/bash
# Locate client.py file
fd -g client.py infrahub_sdk
# Search for sync branch assignment
rg -n 'url_params\["branch"\]' -C5 infrahub_sdk/client.py
# Search for branch_name usage
rg -n 'branch_name' -C5 infrahub_sdk/client.py
# Search for async functions where branch is set
rg -n 'async def' -C5 infrahub_sdk/client.pyLength of output: 35479
Apply conditional branch precedence in both REST query methods
– In infrahub_sdk/client.py around line 1106 (async query_gql_query) and line 2245 (sync REST query), replace
url_params["branch"] = branch_name or self.default_branchwith:
if branch_name:
url_params["branch"] = branch_name
elif "branch" not in url_params and self.default_branch:
url_params["branch"] = self.default_branch– Optional: extract this block into a BaseClient helper to DRY both call sites.
🤖 Prompt for AI Agents
In infrahub_sdk/client.py around lines 1106 (async query_gql_query) and 2245
(sync REST query), the branch parameter is unconditionally set using
"branch_name or self.default_branch"; change it to conditionally prefer an
explicit branch_name, only add default_branch if no "branch" already exists in
url_params and self.default_branch is set (i.e., if branch_name: set
url_params["branch"]=branch_name; elif "branch" not in url_params and
self.default_branch: set url_params["branch"]=self.default_branch). Apply the
same logic to both call sites, and optionally extract this logic into a
BaseClient helper method to avoid duplication and call it from both locations.
7ae0053 to
4dde424
Compare
|
it looks like at least some of the client-related code expects the for example in where so maybe what we really need is a client config option like, |
Fixes #236.
Summary by CodeRabbit
Bug Fixes
Documentation