Skip to content

feat: add IPAddress attribute kind support [INFP-551]#1190

Merged
dgarros merged 1 commit into
infrahub-developfrom
ipaddress-attribute-kind-infp-551
Jul 22, 2026
Merged

feat: add IPAddress attribute kind support [INFP-551]#1190
dgarros merged 1 commit into
infrahub-developfrom
ipaddress-attribute-kind-infp-551

Conversation

@PhillSimonds

@PhillSimonds PhillSimonds commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds SDK support for the new IPAddress attribute kind (bare IP address, no netmask/prefix), alongside the existing IPHost and IPNetwork kinds. Part of the cross-stack work for Infrahub INFP-551 (targets the Infrahub 1.11 cycle).

Kind Python mapping Value type Stores
IPAddress (new) ipaddress.ip_address IPv4Address | IPv6Address bare 192.0.2.1
IPHost ipaddress.ip_interface IPv4Interface | IPv6Interface 192.0.2.1/24
IPNetwork ipaddress.ip_network IPv4Network | IPv6Network 192.0.2.0/24

Changes

  • protocols_base.py: new IPAddress / IPAddressOptional attribute types.
  • protocols_generator/constants.py: ATTRIBUTE_KIND_MAP entry.
  • schema/main.py: AttributeKind.IPADDRESS.
  • node/attribute.py + node/constants.py: parse via ipaddress.ip_address; serialize bare addresses with str() (no with_prefixlen).
  • protocols_generator/template.j2: import the new types so generated protocols reference them.
  • Unit tests for input-data serialization and deserialization (async + sync).

Testing

  • uv run pytest tests/unit/sdk/test_node.py — 228 passed.
  • ruff + mypy clean on changed files.
  • Verified end-to-end against a live Infrahub instance built from the matching backend branch: client.get(...) returns a bare IPv4Address/IPv6Address for an IPAddress attribute, while IPHost/IPNetwork still return prefixed interface/network objects.

Notes

Base branch is infrahub-develop (the branch the Infrahub develop submodule tracks). The Infrahub-side PR bumps the python_sdk submodule pointer only after this merges.

🤖 Generated with Claude Code


Summary by cubic

Adds SDK support for a new IPAddress attribute kind to store and return bare IPv4/IPv6 addresses without a prefix. This fulfills INFP-551 by enabling schemas to validate and serialize plain IPs without the implicit /32 or /128.

  • New Features
    • Added AttributeKind.IPADDRESS and mapping in protocol generator.
    • Introduced IPAddress and IPAddressOptional protocol types (ipaddress.IPv4Address | IPv6Address).
    • Parse with ipaddress.ip_address; serialize as a bare string (no prefix). IPHost/IPNetwork behavior unchanged.
    • Updated node attribute parsing and GraphQL payload generation to handle bare IPs.
    • Added unit tests for sync/async serialization and deserialization.

Written for commit 7997dd3. Summary will update on new commits.

Review in cubic

Support the new bare-IP `IPAddress` attribute kind alongside IPHost/IPNetwork:
- IPAddress/IPAddressOptional protocol types (IPv4Address | IPv6Address)
- ATTRIBUTE_KIND_MAP + AttributeKind enum entries
- parse via ipaddress.ip_address; serialize bare addresses with str() (no prefix)
- import the new types in the protocols generator template
- unit tests for input-data serialization and deserialization

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7997dd3
Status: ✅  Deploy successful!
Preview URL: https://d11c48be.infrahub-sdk-python.pages.dev
Branch Preview URL: https://ipaddress-attribute-kind-inf.infrahub-sdk-python.pages.dev

View logs

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop    #1190      +/-   ##
====================================================
+ Coverage             83.03%   83.12%   +0.08%     
====================================================
  Files                   139      139              
  Lines                 12365    12413      +48     
  Branches               1846     1851       +5     
====================================================
+ Hits                  10267    10318      +51     
+ Misses                 1531     1528       -3     
  Partials                567      567              
Flag Coverage Δ
integration-tests 40.36% <25.00%> (-0.15%) ⬇️
python-3.10 56.96% <41.66%> (+0.01%) ⬆️
python-3.11 56.98% <41.66%> (+0.02%) ⬆️
python-3.12 56.98% <41.66%> (+0.02%) ⬆️
python-3.13 56.96% <41.66%> (+0.01%) ⬆️
python-3.14 56.96% <41.66%> (+0.02%) ⬆️
python-filler-3.12 22.41% <58.33%> (+0.09%) ⬆️

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%> (ø)
infrahub_sdk/node/constants.py 100.00% <100.00%> (ø)
infrahub_sdk/protocols_base.py 78.29% <100.00%> (+0.69%) ⬆️
infrahub_sdk/protocols_generator/constants.py 100.00% <ø> (ø)
infrahub_sdk/schema/main.py 91.11% <100.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 9 files

Re-trigger cubic

@dgarros
dgarros merged commit f7f73d5 into infrahub-develop Jul 22, 2026
21 checks passed
@dgarros
dgarros deleted the ipaddress-attribute-kind-infp-551 branch July 22, 2026 04:02
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.

2 participants