Skip to content

Add description field to InfrahubPythonTransformConfig#887

Open
minitriga wants to merge 1 commit intoinfrahub-developfrom
gh-6382-python-transform-description
Open

Add description field to InfrahubPythonTransformConfig#887
minitriga wants to merge 1 commit intoinfrahub-developfrom
gh-6382-python-transform-description

Conversation

@minitriga
Copy link
Contributor

@minitriga minitriga commented Mar 23, 2026

Summary

Fixes opsmill/infrahub#6382 — Python transforms in .infrahub.yml don't support a description field, even though Jinja2 transforms do and both types appear in the same table in the Infrahub UI.

  • Add optional description: str | None field to InfrahubPythonTransformConfig, matching the existing field on InfrahubJinja2TransformConfig
  • Add unit test covering description field parsing (present, absent, explicit None)

Before / After

Before: Setting description on a Python transform in .infrahub.yml raises a validation error (extra="forbid").

After:

python_transforms:
  - name: MyTransform
    description: "Converts device data to OpenConfig format"  # now accepted
    file_path: "transforms/my_transform.py"
    class_name: MyTransform

Test plan

  • InfrahubPythonTransformConfig accepts description with a string value
  • InfrahubPythonTransformConfig defaults description to None when omitted
  • Existing configs without description continue to parse (backward compatible)
  • All 53 SDK schema tests pass

🤖 Generated with Claude Code

@minitriga minitriga requested a review from a team as a code owner March 23, 2026 17:17
@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Mar 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Warning

Rate limit exceeded

@minitriga has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 25 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: b9b6c818-edb4-40f8-9d55-0f5bbfc1f4eb

📥 Commits

Reviewing files that changed from the base of the PR and between 1483819 and 91b815e.

📒 Files selected for processing (2)
  • infrahub_sdk/schema/repository.py
  • tests/unit/sdk/test_schema.py

Walkthrough

The pull request makes three primary sets of changes to the Infrahub SDK. First, it removes the deprecated raise_for_error parameter from multiple client methods (execute_graphql, query_gql_query, get_diff_summary, allocate_next_ip_address, and allocate_next_ip_prefix) across both async and sync variants, updates their documentation, and removes the associated deprecation warning helper. Second, it adds new protocol node types for key/value data (CoreKeyValue, CoreEnvKeyValue, CoreStaticKeyValue and their sync variants) and extends webhook protocols with a headers relationship field. Third, it introduces optional description field support to the InfrahubPythonTransformConfig model to enable Python transforms to include descriptions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several unrelated changes are included: removal of deprecated raise_for_error parameter, addition of CoreKeyValue protocol nodes, and updates to WebhookSync—these extend beyond the stated scope of adding description support to Python transforms. Move the raise_for_error removal, CoreKeyValue protocol additions, and WebhookSync updates into separate focused PRs to keep this PR scoped solely to the description field feature.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: adding a description field to InfrahubPythonTransformConfig, which aligns with the primary modification across the changeset.
Linked Issues check ✅ Passed The changeset fully implements the linked issue #6382 requirement by adding the optional description field to InfrahubPythonTransformConfig with appropriate tests, enabling parity with Jinja2 transforms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is well-structured, providing context, motivation, implementation details, test coverage, and a clear test plan.

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

❤️ Share

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

minitriga added a commit to opsmill/infrahub that referenced this pull request Mar 23, 2026
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>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 23, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

@gmazoyer
Copy link
Contributor

If you target develop for the Infrahub change, this PR should target infrahub-develop instead of develop

@codecov
Copy link

codecov bot commented Mar 23, 2026

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           
Flag Coverage Δ
integration-tests 39.98% <0.00%> (-0.01%) ⬇️
python-3.10 52.52% <0.00%> (-0.01%) ⬇️
python-3.11 52.52% <0.00%> (-0.01%) ⬇️
python-3.12 52.52% <0.00%> (-0.01%) ⬇️
python-3.13 52.52% <0.00%> (-0.03%) ⬇️
python-3.14 54.22% <0.00%> (-0.01%) ⬇️
python-filler-3.12 23.75% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/schema/repository.py 89.77% <100.00%> (+0.05%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@minitriga minitriga force-pushed the gh-6382-python-transform-description branch from 1483819 to c313155 Compare March 23, 2026 17:22
@minitriga minitriga changed the base branch from develop to infrahub-develop March 23, 2026 17:23
@minitriga minitriga force-pushed the gh-6382-python-transform-description branch from c313155 to 09eafd0 Compare March 23, 2026 17:24
@github-actions github-actions bot added the group/ci Issue related to the CI pipeline label Mar 23, 2026
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>
@minitriga minitriga force-pushed the gh-6382-python-transform-description branch from 09eafd0 to 91b815e Compare March 23, 2026 17:24
@github-actions github-actions bot removed group/ci Issue related to the CI pipeline type/documentation Improvements or additions to documentation labels Mar 23, 2026
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.

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 | 🟡 Minor

The prose here still describes the old contract.

These sections updated the signatures, but the narrative still says execute_graphql only raises GraphQLError and that the allocation helpers return InfrahubNode / InfrahubNodeSync. That no longer matches the new signature/behavior. Please update the source docstrings in infrahub_sdk/client.py and regenerate this reference page.

Based on learnings, "Do not edit files in docs/python-sdk/sdk_ref/**/*.mdx directly; regenerate with uv 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 | 🔴 Critical

Add a fallback raise statement in both execute_graphql exception handlers to re-raise non-auth HTTP errors.

The except httpx.HTTPStatusError handlers only translate 401/403/404 status codes. Any other 4xx/5xx error is silently dropped: with retry_on_failure=True this replays queries/mutations in a loop until max_retry_duration expires, and with retries disabled the code falls through to decode_json() attempting to parse an error response as valid data. Add a final raise statement 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

📥 Commits

Reviewing files that changed from the base of the PR and between dc6b9c4 and 1483819.

📒 Files selected for processing (8)
  • changelog/+infp380.removed.md
  • docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx
  • infrahub_sdk/client.py
  • infrahub_sdk/ctl/utils.py
  • infrahub_sdk/ctl/validate.py
  • infrahub_sdk/protocols.py
  • infrahub_sdk/schema/repository.py
  • tests/unit/sdk/test_schema.py
💤 Files with no reviewable changes (2)
  • infrahub_sdk/ctl/utils.py
  • infrahub_sdk/ctl/validate.py

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.

3 participants