Add description field to InfrahubPythonTransformConfig#887
Add description field to InfrahubPythonTransformConfig#887minitriga wants to merge 1 commit intoinfrahub-developfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe pull request makes three primary sets of changes to the Infrahub SDK. First, it removes the deprecated 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Thread the optional `description` field through the Python transform pipeline: get_python_transforms → create/compare/update methods. This achieves parity with Jinja2 transform description handling. The SDK-side change (InfrahubPythonTransformConfig.description) is in opsmill/infrahub-sdk-python#887. Closes #6382 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
91b815e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1949afe7.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://gh-6382-python-transform-des.infrahub-sdk-python.pages.dev |
|
If you target |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #887 +/- ##
=================================================
Coverage 80.98% 80.98%
=================================================
Files 120 120
Lines 10449 10450 +1
Branches 1562 1562
=================================================
+ Hits 8462 8463 +1
Misses 1475 1475
Partials 512 512
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
1483819 to
c313155
Compare
c313155 to
09eafd0
Compare
Add an optional `description` field to `InfrahubPythonTransformConfig` to achieve parity with `InfrahubJinja2TransformConfig`. This allows users to set descriptions for Python transforms in `.infrahub.yml`. Closes opsmill/infrahub#6382 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
09eafd0 to
91b815e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx (1)
225-245:⚠️ Potential issue | 🟡 MinorThe prose here still describes the old contract.
These sections updated the signatures, but the narrative still says
execute_graphqlonly raisesGraphQLErrorand that the allocation helpers returnInfrahubNode/InfrahubNodeSync. That no longer matches the new signature/behavior. Please update the source docstrings ininfrahub_sdk/client.pyand regenerate this reference page.Based on learnings, "Do not edit files in
docs/python-sdk/sdk_ref/**/*.mdxdirectly; regenerate withuv run invoke docs-generate."Also applies to: 290-361, 506-526, 676-747
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx` around lines 225 - 245, The docs text is out-of-date: update the source docstrings in infrahub_sdk/client.py to match the new function signatures/behavior (e.g., execute_graphql now may raise additional exceptions and the allocation helpers return different types than InfrahubNode/InfrahubNodeSync); edit the docstring for execute_graphql (and the allocation helper functions) to accurately list new parameters, return types, and raised exceptions, then regenerate the reference MDX files by running the documented command (uv run invoke docs-generate) so docs/python-sdk/sdk_ref/**/*.mdx are updated accordingly.infrahub_sdk/client.py (1)
946-965:⚠️ Potential issue | 🔴 CriticalAdd a fallback
raisestatement in bothexecute_graphqlexception handlers to re-raise non-auth HTTP errors.The
except httpx.HTTPStatusErrorhandlers only translate 401/403/404 status codes. Any other 4xx/5xx error is silently dropped: withretry_on_failure=Truethis replays queries/mutations in a loop untilmax_retry_durationexpires, and with retries disabled the code falls through todecode_json()attempting to parse an error response as valid data. Add a finalraisestatement in both the async (InfrahubClient.execute_graphql) and sync (InfrahubClientSync.execute_graphql) implementations.Suggested fix
except httpx.HTTPStatusError as exc: if exc.response.status_code in {401, 403}: response = decode_json(response=exc.response) errors = response.get("errors", []) messages = [error.get("message") for error in errors] raise AuthenticationError(" | ".join(messages)) from exc if exc.response.status_code == 404: raise URLNotFoundError(url=url) from exc + raise🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@infrahub_sdk/client.py` around lines 946 - 965, The httpx.HTTPStatusError handlers in InfrahubClient.execute_graphql and InfrahubClientSync.execute_graphql currently only handle 401/403/404 and then continue execution for all other status codes; update both except blocks to re-raise the original exception for any unhandled status codes (i.e., after the 401/403 block and after the 404 block add a final "raise" to propagate exc) so non-auth HTTP errors are not swallowed and will surface to the caller.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx`:
- Around line 225-245: The docs text is out-of-date: update the source
docstrings in infrahub_sdk/client.py to match the new function
signatures/behavior (e.g., execute_graphql now may raise additional exceptions
and the allocation helpers return different types than
InfrahubNode/InfrahubNodeSync); edit the docstring for execute_graphql (and the
allocation helper functions) to accurately list new parameters, return types,
and raised exceptions, then regenerate the reference MDX files by running the
documented command (uv run invoke docs-generate) so
docs/python-sdk/sdk_ref/**/*.mdx are updated accordingly.
In `@infrahub_sdk/client.py`:
- Around line 946-965: The httpx.HTTPStatusError handlers in
InfrahubClient.execute_graphql and InfrahubClientSync.execute_graphql currently
only handle 401/403/404 and then continue execution for all other status codes;
update both except blocks to re-raise the original exception for any unhandled
status codes (i.e., after the 401/403 block and after the 404 block add a final
"raise" to propagate exc) so non-auth HTTP errors are not swallowed and will
surface to the caller.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d536ee95-b0f5-47e3-8820-4466935a9bae
📒 Files selected for processing (8)
changelog/+infp380.removed.mddocs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdxinfrahub_sdk/client.pyinfrahub_sdk/ctl/utils.pyinfrahub_sdk/ctl/validate.pyinfrahub_sdk/protocols.pyinfrahub_sdk/schema/repository.pytests/unit/sdk/test_schema.py
💤 Files with no reviewable changes (2)
- infrahub_sdk/ctl/utils.py
- infrahub_sdk/ctl/validate.py
Summary
Fixes opsmill/infrahub#6382 — Python transforms in
.infrahub.ymldon't support adescriptionfield, even though Jinja2 transforms do and both types appear in the same table in the Infrahub UI.description: str | Nonefield toInfrahubPythonTransformConfig, matching the existing field onInfrahubJinja2TransformConfigBefore / After
Before: Setting
descriptionon a Python transform in.infrahub.ymlraises a validation error (extra="forbid").After:
Test plan
InfrahubPythonTransformConfigacceptsdescriptionwith a string valueInfrahubPythonTransformConfigdefaultsdescriptiontoNonewhen omitteddescriptioncontinue to parse (backward compatible)🤖 Generated with Claude Code