feat(node): return bare IP addresses for attributes declaring allow_prefix [INFP-551] - #1220
Open
ajtmccarty wants to merge 4 commits into
Open
feat(node): return bare IP addresses for attributes declaring allow_prefix [INFP-551]#1220ajtmccarty wants to merge 4 commits into
ajtmccarty wants to merge 4 commits into
Conversation
…refix [INFP-551] An IPHost attribute whose schema sets parameters.allow_prefix to false stores a bare address, so parsing it as an interface re-attached the host mask at the SDK boundary. Value coercion and the generated-protocol annotation now read the flag, tolerantly defaulting to the prefixed behaviour when a server does not publish it. Removes the unreachable IPAddress attribute-kind branch: no such attribute kind exists on the server, and the bare-address coercion it referenced is what the flagged IPHost branch now uses. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
@@ Coverage Diff @@
## infrahub-develop #1220 +/- ##
====================================================
- Coverage 83.69% 77.48% -6.22%
====================================================
Files 144 144
Lines 12754 12776 +22
Branches 1859 1863 +4
====================================================
- Hits 10674 9899 -775
- Misses 1516 2326 +810
+ Partials 564 551 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 34 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…g a coercer _value_coercer returned a callable that was invoked immediately at its only call site, so the indirection bought nothing. Coerce in place instead, and drop the now-unused Callable import. Also trims the parameter comments to a single line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vale rejects 'onwards'. The warning admonition below already says 'or later', so this matches it. Edited in the Jinja2 template, since compatibility.mdx is generated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
525b28f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://64e0058c.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://infp-551-bare-ip-attribute.infrahub-sdk-python.pages.dev |
ajtmccarty
marked this pull request as ready for review
July 30, 2026 01:20
…ption Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Counterpart to opsmill/infrahub#10081, the first PR in the Infrahub-side stack for INFP-551.
Why
Infrahub is gaining a
parameters.allow_prefixdeclaration onIPHostattributes. When it isfalse, theattribute holds a bare IP address —
10.0.0.1rather than the10.0.0.1/32the server previouslyinvented — and a real subnet prefix is refused.
Without this change the SDK re-attaches the mask the server just removed: every
IPHostresponse is parsedwith
ipaddress.ip_interface, so a bare10.0.0.1becomesIPv4Interface('10.0.0.1/32')and the maskreappears at the SDK boundary. That directly contradicts the feature's contract, which is why this ships
alongside the server change rather than after it.
What changed
node/attribute.py): forIPHost, selectipaddress.ip_addresswhenallow_prefixis
Falseandipaddress.ip_interfaceotherwise. The flag is read tolerantly as(self._schema.parameters or {}).get("allow_prefix", True), becauseAttributeSchemaAPI.parametersisdict[str, Any] | None— an SDK talking to an older server that does not send the key behaves exactly asit does today.
"IPAddress"kind key. No such attribute kind exists server-side: the generatedAttributeKindenum has noIPADDRESSmember, and two tests exercising it were already skipped citingthat. The
ip_addresscallable it referenced becomes the declared-IPHostbranch.protocols_generator/generator.py): emitIPAddress/IPAddressOptionalfor adeclared attribute,
IPHost/IPHostOptionalotherwise, composing with the existingoptional and default_value is Nonesuffix rule. All four protocol names were already registered andimported, so no change was needed to
constants.py,protocols_base.py, ortemplate.j2.schema/generated/{read,write}.py, which gainIPHostAttributeParameters{Read,Write}andIPHostAttribute{Read,Write}, withAttributeKind.IPHOSTmoving out of the generic variant.Why the generated models matter to the server
More than a type nicety:
SchemaLoadAPIon the server inherits these write models. WithoutIPHostAttributeWrite, anIPHostattribute matchesGenericAttributeWrite, whoseparametersisfield-less with
extra="ignore"— soallow_prefixis silently dropped from every schema-load payloadand the server-side feature is inert. The Infrahub PR cannot pass CI until this branch is available.
How to review
node/attribute.pyandprotocols_generator/generator.pyare the whole change; everything else isgenerated output or tests.
Coverage follows a three-way pattern rather than two: declared, undeclared, and schema payload
with no
allow_prefixkey at all — the last being the old-server tolerance case, which is the one mostlikely to regress silently.
test_node_IPHost_deserialization_honours_allow_prefix— 7 cases × 2 client typestest_filter_render_iphost_attribute— 8 casesIPAddresstests repurposed onto declaredIPHostrather than deletedMerge order
This should merge before opsmill/infrahub#10081. That PR pins this branch's commit provisionally so
both can be reviewed in parallel; once this merges, the Infrahub submodule pointer is re-pinned to the
merged commit and confirmed an ancestor of
infrahub-develop.Summary by cubic
Return bare IP addresses for
IPHostattributes that setparameters.allow_prefix: false, and mark them asIPAddressin generated protocols. Addresses INFP-551 by delivering bare IPs without a new attribute kind, while keeping old-server behavior.New Features
IPHostwithipaddress.ip_addresswhenallow_prefixis false; otherwise useipaddress.ip_interface.IPAddress/IPAddressOptionaltypes for flaggedIPHost; otherwise keepIPHost/IPHostOptional.IPHostAttribute{Read,Write}withparameters.allow_prefix(regenerated after description tweak) and update compatibility docs with min versions (SDK ≥ 1.23.0, Infrahub ≥ 1.11).Migration
IPv4Address/IPv6Address(no mask) instead of interfaces.allow_prefixis absent, values remain interfaces. The server must be ≥ 1.11 to publish the flag.Written for commit 525b28f. Summary will update on new commits.