Skip to content

Merge develop into infrahub-develop#856

Merged
polmichel merged 12 commits intoinfrahub-developfrom
pmi-20260226-merge-develop-into-infrahub-develop
Feb 27, 2026
Merged

Merge develop into infrahub-develop#856
polmichel merged 12 commits intoinfrahub-developfrom
pmi-20260226-merge-develop-into-infrahub-develop

Conversation

@polmichel
Copy link

@polmichel polmichel commented Feb 26, 2026

Why

Manual merge of develop into infrahub-develop due to merge conflicts. This PR replaces #852.

What changed

  • Typing in tests
  • Linting rules: MDX is not accepted as a spelling exception

It includes #850 & #829.

Summary by CodeRabbit

  • New Features

    • Added an SDK method to detect pool-sourced attribute values.
  • Bug Fixes

    • Fixed Python SDK query generation for pool-sourced attribute values.
  • Documentation

    • Clarified and standardized docs (headings, examples); added developer guides for feedback and pre-CI; added changelog entry.
  • Tests

    • Added and reorganized comprehensive unit tests for pool allocation, pool attributes, and related behaviors.
  • Chores

    • Updated linting/spelling rules to exempt MDX terminology.

polmichel and others added 10 commits February 20, 2026 12:14
New /pre-ci & /feedback commands for Claude
…850)

* IHS-156 fix SDK from_pool attribute management before querying GraphQL API

* IHS-156 refactor the test cases to have a better view on the tests perimeter

* towncrier regarding Github issue #497

* IHS-156 update AGENTS doc using the command /feedback

* IHS-156 is_from_pool_attribute typing and naming

* IHS-156 refactor generate_input_data

* IHS-156 remove Jira issue related comment in the tests

* IHS-156 removed a part of fixtures to upper level

* IHS-156 tested all cases of generated_input_data

* IHS-156 fixed a bug in test_relationship_from_pool.py

* IHS-156 side effect bugs regarding from_pool attributes

* IHS-156 last feedbacks regarding documentation and variable naming

* IHS-156 fix typing error

* IHS-156 renamed payload_dict -> payload
…-develop-into-infrahub-develop

# Conflicts:
#	tests/unit/sdk/conftest.py
@polmichel polmichel self-assigned this Feb 26, 2026
@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Feb 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Walkthrough

Refactors SDK attribute GraphQL payload handling: adds _GraphQLPayloadAttribute and is_from_pool_attribute() in infrahub_sdk/node/attribute.py, changes _generate_input_data to return the new payload type, and updates _generate_mutation_query. Updates InfrahubNodeBase._generate_input_data signature to accept request_context and to consume payloads via graphql_payload.payload/graphql_payload.variables; mutation result processing now uses is_from_pool_attribute(). Adds/updates docs (style, MDX exception, feedback and pre-CI guides) and reorganizes/extends unit tests for pool allocation, pool queries, and attribute-from-pool behavior.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.99% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is vague and lacks detail about the scope and behavioral changes. It mentions 'Manual merge' but provides limited technical information about what is being merged. Expand the description with concrete details about the functional changes being merged (e.g., from_pool attribute support), the rationale for the manual merge, and how this resolves PR #852. Include sections on 'What changed,' 'Testing,' and 'Backward compatibility' as outlined in the template.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Merge develop into infrahub-develop' directly describes the main change, which is a branch merge operation.

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 52d475e
Status: ✅  Deploy successful!
Preview URL: https://667cdbf9.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pmi-20260226-merge-develop-i.infrahub-sdk-python.pages.dev

View logs

@polmichel polmichel marked this pull request as ready for review February 26, 2026 23:12
@polmichel polmichel requested a review from a team as a code owner February 26, 2026 23:12
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.

🧹 Nitpick comments (3)
tests/unit/sdk/pool/test_attribute_from_pool.py (1)

133-204: Consider adding sync client tests for node-based from_pool.

The node-based from_pool tests (lines 140-204) only cover the async client. For parity with the dict-based tests that cover both async and sync paths, consider adding corresponding sync client tests for test_attribute_with_pool_node_generates_from_pool and test_attribute_with_pool_node_generates_mutation_query.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/sdk/pool/test_attribute_from_pool.py` around lines 133 - 204,
Tests only exercise async client paths for node-based from_pool; add mirror
sync-client tests to ensure parity. Duplicate the two async test cases
test_attribute_with_pool_node_generates_from_pool and
test_attribute_with_pool_node_generates_mutation_query but construct
InfrahubNode instances using the sync client fixture (e.g., a sync client name
used elsewhere in dict-based tests), call the sync equivalents of
_generate_input_data and _generate_mutation_query on the nodes, and assert the
same expectations (vlan_id from_pool id and mutation object value None). Use the
same helper symbols (InfrahubNode, vlan_schema, ipaddress_pool_schema,
ipam_ipprefix_schema, ipam_ipprefix_data, NODE_POOL_ID) so the new tests mirror
the async ones exactly but target the sync code paths.
tests/unit/sdk/test_attribute_generate_input_data.py (1)

360-404: _FakeNode is missing get_node_metadata method from CoreNodeBase protocol.

Per infrahub_sdk/protocols_base.py lines 175-206, the CoreNodeBase protocol requires a get_node_metadata(self) -> NodeMetadata | None method. While the current tests pass because the tested code paths don't invoke this method, adding it would ensure full protocol compliance and prevent potential issues if future code changes require it.

♻️ Add missing protocol method
     def get_raw_graphql_data(self) -> dict | None:
         return None
+
+    def get_node_metadata(self) -> None:
+        return None
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/sdk/test_attribute_generate_input_data.py` around lines 360 - 404,
The _FakeNode test stub lacks the protocol-required method get_node_metadata;
add a method def get_node_metadata(self) -> NodeMetadata | None: that returns
None (or a minimal NodeMetadata instance if tests need it) to satisfy the
CoreNodeBase protocol; update the _FakeNode class in the test file (referencing
_FakeNode and CoreNodeBase) and import or reference NodeMetadata as needed so
the signature type is correct.
infrahub_sdk/node/attribute.py (1)

139-158: Minor docstring inconsistency.

The docstring mentions "Returns a ResolvedValue object" but the actual return type is _GraphQLPayloadAttribute. Consider updating for accuracy.

📝 Fix docstring
     def _generate_input_data(self) -> _GraphQLPayloadAttribute:
         """Build the input payload for a GraphQL mutation on this attribute.

-        Returns a ResolvedValue object, which contains all the data required.
+        Returns a _GraphQLPayloadAttribute object, which contains all the data required.
         """
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@infrahub_sdk/node/attribute.py` around lines 139 - 158, Update the docstring
for the method _generate_input_data to accurately state the return type and
purpose: replace the incorrect "Returns a ResolvedValue object" text with a
description that it returns a _GraphQLPayloadAttribute (or the appropriate
GraphQL payload type) and optionally mention it builds the input payload for a
GraphQL mutation; ensure the one-line summary and the Returns section reference
_GraphQLPayloadAttribute and keep the existing brief description of the method's
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@infrahub_sdk/node/attribute.py`:
- Around line 139-158: Update the docstring for the method _generate_input_data
to accurately state the return type and purpose: replace the incorrect "Returns
a ResolvedValue object" text with a description that it returns a
_GraphQLPayloadAttribute (or the appropriate GraphQL payload type) and
optionally mention it builds the input payload for a GraphQL mutation; ensure
the one-line summary and the Returns section reference _GraphQLPayloadAttribute
and keep the existing brief description of the method's behavior.

In `@tests/unit/sdk/pool/test_attribute_from_pool.py`:
- Around line 133-204: Tests only exercise async client paths for node-based
from_pool; add mirror sync-client tests to ensure parity. Duplicate the two
async test cases test_attribute_with_pool_node_generates_from_pool and
test_attribute_with_pool_node_generates_mutation_query but construct
InfrahubNode instances using the sync client fixture (e.g., a sync client name
used elsewhere in dict-based tests), call the sync equivalents of
_generate_input_data and _generate_mutation_query on the nodes, and assert the
same expectations (vlan_id from_pool id and mutation object value None). Use the
same helper symbols (InfrahubNode, vlan_schema, ipaddress_pool_schema,
ipam_ipprefix_schema, ipam_ipprefix_data, NODE_POOL_ID) so the new tests mirror
the async ones exactly but target the sync code paths.

In `@tests/unit/sdk/test_attribute_generate_input_data.py`:
- Around line 360-404: The _FakeNode test stub lacks the protocol-required
method get_node_metadata; add a method def get_node_metadata(self) ->
NodeMetadata | None: that returns None (or a minimal NodeMetadata instance if
tests need it) to satisfy the CoreNodeBase protocol; update the _FakeNode class
in the test file (referencing _FakeNode and CoreNodeBase) and import or
reference NodeMetadata as needed so the signature type is correct.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a17f18b and 97e4a8b.

📒 Files selected for processing (24)
  • .vale/styles/Infrahub/sentence-case.yml
  • .vale/styles/spelling-exceptions.txt
  • AGENTS.md
  • changelog/497.fixed.md
  • dev/commands/feedback.md
  • dev/commands/pre-ci.md
  • docs/AGENTS.md
  • docs/docs/python-sdk/guides/client.mdx
  • docs/docs/python-sdk/guides/python-typing.mdx
  • docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx
  • docs/docs/python-sdk/topics/object_file.mdx
  • infrahub_sdk/node/attribute.py
  • infrahub_sdk/node/node.py
  • tests/AGENTS.md
  • tests/unit/sdk/conftest.py
  • tests/unit/sdk/pool/__init__.py
  • tests/unit/sdk/pool/conftest.py
  • tests/unit/sdk/pool/test_allocate.py
  • tests/unit/sdk/pool/test_attribute_from_pool.py
  • tests/unit/sdk/pool/test_pool_queries.py
  • tests/unit/sdk/pool/test_relationship_from_pool.py
  • tests/unit/sdk/test_attribute_generate_input_data.py
  • tests/unit/sdk/test_client.py
  • tests/unit/sdk/test_node.py
💤 Files with no reviewable changes (2)
  • tests/unit/sdk/test_node.py
  • tests/unit/sdk/test_client.py

@polmichel polmichel marked this pull request as draft February 26, 2026 23:20
@polmichel polmichel force-pushed the pmi-20260226-merge-develop-into-infrahub-develop branch from 97e4a8b to 52d475e Compare February 26, 2026 23:34
)
ip_address = clients.sync.allocate_next_ip_address(
resource_pool=ip_pool,
resource_pool=cast("CoreNodeSync", ip_pool),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how we should handle this case.
This is a type mismatch, but fixing this would end up changing the type of a parameter in the public method allocate_next_ip_address...

)
ip_prefix = await clients.standard.allocate_next_ip_prefix(
resource_pool=ip_pool,
resource_pool=cast("CoreNode", ip_pool),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See upper comment but for the methodallocate_next_ip_prefix

@polmichel polmichel marked this pull request as ready for review February 26, 2026 23:37
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/node/node.py 80.00% 0 Missing and 2 partials ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #856      +/-   ##
====================================================
- Coverage             81.80%   80.66%   -1.14%     
====================================================
  Files                   118      118              
  Lines                 11976    10246    -1730     
  Branches               2066     1534     -532     
====================================================
- Hits                   9797     8265    -1532     
+ Misses                 1551     1454      -97     
+ Partials                628      527     -101     
Flag Coverage Δ
integration-tests 40.35% <56.86%> (-2.63%) ⬇️
python-3.10 51.82% <74.50%> (-2.62%) ⬇️
python-3.11 51.82% <74.50%> (-2.62%) ⬇️
python-3.12 51.84% <74.50%> (-2.60%) ⬇️
python-3.13 51.84% <74.50%> (-2.60%) ⬇️
python-3.14 53.53% <74.50%> (-3.01%) ⬇️
python-filler-3.12 24.03% <21.56%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/node/attribute.py 100.00% <100.00%> (+4.54%) ⬆️
infrahub_sdk/node/node.py 85.81% <80.00%> (-3.03%) ⬇️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@polmichel polmichel merged commit 1c1407d into infrahub-develop Feb 27, 2026
21 checks passed
@polmichel polmichel deleted the pmi-20260226-merge-develop-into-infrahub-develop branch February 27, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants