Add maskless `IPAddress` attribute kind
partner PR in the SDK repo https://github.com/opsmill/infrahub-sdk-python/pull/1222
Why
IPHost is the only IP-address attribute kind, and it is backed by ipaddress.ip_interface(), so it always carries a prefix: 192.0.2.1 is stored as 192.0.2.1/32. Wherever the prefix is not part of the data — a DNS record target, a syslog destination, a BGP neighbour — that suffix leaks into display labels, HFIDs and API payloads with no way to opt out.
Adds an IPAddress attribute kind that accepts only a bare address and rejects anything carrying a prefix or netmask.
Non-goals: no change to IPHost/IPNetwork behaviour, no new IPAM capability, and no core schema attribute switches to the new kind.
Closes IFC-2947
What changed
Behavioral changes:
- New
IPAddressattribute kind.10.0.0.1and2001:db8::1are accepted;10.0.0.1/32,10.0.0.1/24,10.0.0.0/255.255.255.0and leading-zero forms such as010.0.0.1are rejected. IPv6 is normalized to its compressed lowercase form (2001:0DB8::0001→2001:db8::1), and an IPv4-mapped address keeps its family (::ffff:10.0.0.1). - Exposed as a distinct GraphQL type (
__typename: "IPAddress") withvalueandversion. The filter surface is identical toIPHost—__value,__values,__isnull,__source__id,__owner__id,__is_protected— because filters are derived generically andIPHostnever exposed a prefix filter. - In the UI it renders as a plain text input, appears as a list-view column, and offers a text filter. A prefixed value is rejected inline in the form rather than round-tripping to a backend 400.
- Changing an attribute's kind is now rejected when the stored values are not already canonical for the new kind. A kind change runs no data migration, so switching to
IPHostpreviously left a bare10.0.0.1in the database while the canonical form is10.0.0.1/32, silently breaking__valuefilters and uniqueness comparisons. This is the one pre-existing behaviour this PR changes, and it affects conversions intoIPHost,IPNetwork,IPAddressandMacAddress— for exampleText→MacAddressoveraa-bb-cc-dd-ee-ffis now refused. - GraphQL rejects a prefixed value with
10.0.0.1/24 is not a valid IPAddress at target, and a schema load that flipsIPAddress→IPHost(or the reverse) is refused per node with the offending value, leaving the schema and data unchanged.
Implementation notes:
- The new kind reuses the existing
AttributeIPHostvalue vertex in cypher rather than introducing its own label.prefixlenis stored as the family maximum because the sharedMERGEinterpolates it and neo4j rejects a null property; it is deliberately absent from the GraphQL type and fromget_allowed_property_in_path(), so it is not queryable. - The canonicality check needs no list of the kinds it applies to. Kinds that do not normalize inherit an identity
_normalize_value(), so the check is a no-op for them and a future normalizing kind is covered without touching the validator._normalize_value()became aclassmethodso a value can be checked without constructing an attribute; no override used instance state, so behaviour is unchanged. ATTRIBUTE_PYTHON_TYPES["IPAddress"]isIPvAnyAddress, which is genuinely correct here — unlike the existingIPHostentry, which uses the same type despiteIPvAnyAddressrejecting10.0.0.1/32, the canonicalIPHostvalue.
What stayed the same: no graph migration, no GRAPH_VERSION change, no new DB label or index, no change to IPHost/IPNetwork semantics, and no core schema node adopts the kind. backend/tests/component/core/graph/test_graph_constraints.py and test_graph_version.py pass unmodified, which is the evidence for that.
Suggested review order
backend/infrahub/types.pyandbackend/infrahub/core/attribute.py— the kind itself and why it reuses theIPHostvertex.backend/infrahub/core/validators/attribute/kind.py— the only pre-existing behaviour this PR changes.frontend/app/src/entities/schema/domain/rules/validation/validate-ip-address-attribute.ts— hand-rolled IPv4/IPv6 parsing.- Everything under
schema/,docs/docs/reference/andfrontend/app/src/shared/api/*/generated/is generated output.
How to review
Focus on the vertex-sharing decision and the kind-change rejection; those carry the risk. The frontend validator deserves scrutiny too — cubic caught two real IPv6 group-counting bugs there (a trailing dotted quad stands for two groups, and :: must stand for at least one), both fixed with regression tests.
Mechanical: the whole of commit chore(generated). Note that graphql-cache.d.ts shows ~132 changed lines, none of which mention IPAddress — it is gql.tada rehashing every cached document because the schema changed.
Worth a second opinion: sharing AttributeIPHost means the label no longer maps one-to-one to a kind, so new Cypher against it must gate on node kind or attribute name, as core/query/ipam.py already does. The alternative was a dedicated label, which costs a GRAPH_VERSION bump plus a migration and would have been silently incomplete anyway, since AttributeKindUpdateMigrationQuery never applies the IP labels on a kind change.
Impact & rollout
- Backward compatibility: additive for the new kind. The kind-change rejection is the exception — schema updates that previously succeeded while corrupting stored values will now fail with a validation error naming each node. Normalize the values first, then change the kind.
- Performance: unchanged. The kind shares the existing indexed vertex. Values sort lexically rather than numerically (
10.0.0.10before10.0.0.2), since the binary index is only reachable through IPAM's own queries. - Config/env changes: none.
- Deployment notes: requires a coordinated release with the SDK.
AttributeSchema.kindis typed to the generatedAttributeKindenum, so an SDK withoutIPADDRESScannot load a schema using the kind. opsmill/infrahub-sdk-python#1222 must merge first; this PR's submodule pointer references it. No database migration is needed.
Checklist
- Tests added/updated
- Changelog entry added (
uv run towncrier create ...) - External docs updated (if user-facing or ops-facing change)
- Internal .md docs updated (internal knowledge and AI code tools knowledge)
- I have reviewed AI generated content
Summary by cubic
Adds a new IPAddress attribute kind for bare IPs and enforces canonical-value checks on kind changes to prevent stale comparisons. Updates the python_sdk submodule to the merged SDK release that includes this kind.
-
New Features
- New
IPAddresskind stores a bare IP (no prefix/netmask). IPv6 normalizes to compressed lowercase. Values sort lexically. - Reuses
AttributeIPHostfor storage; writes family max prefix internally (not exposed). - GraphQL: new
IPAddresstype withvalueandversion; REST/OpenAPI andpython_sdkupdated. - Frontend: input, list/table display, text filters, and validation (rejects values with “/” and malformed IPs).
- Canonical-value check when changing kind; applies to
IPHost,IPNetwork,IPAddress, andMacAddress.
- New
-
Bug Fixes
- Frontend
IPAddressvalidator: correct IPv6 group counting and dotted-quad handling, and require "::" to cover at least one group, aligning with backend parsing.
- Frontend