Skip to content

Fix missing hfid field on RelatedIPAddressNodeInput#8579

Open
BeArchiTek wants to merge 4 commits intostablefrom
fix/8574-ip-address-hfid-input-v2
Open

Fix missing hfid field on RelatedIPAddressNodeInput#8579
BeArchiTek wants to merge 4 commits intostablefrom
fix/8574-ip-address-hfid-input-v2

Conversation

@BeArchiTek
Copy link
Contributor

@BeArchiTek BeArchiTek commented Mar 11, 2026

Summary by CodeRabbit

  • New Features

    • Related IP address and IP prefix relationship inputs now accept optional human-friendly ID (HFID) values, allowing HFID-based referencing when linking related IP nodes.
  • Tests

    • Added a component test validating creation of a device referencing an IP by HFID.
  • Documentation / Types

    • Client-side type definitions updated to reflect the new HFID-capable input shapes.
  • Add missing hfid field to RelatedIPAddressNodeInput GraphQL input type, aligning it with RelatedNodeInput and RelatedIPPrefixNodeInput
  • This allows IP address relationships to be referenced by human-friendly ID (e.g. in object files)
  • Regenerate schema/schema.graphql to include the new field

Fixes #8574

Test plan

  • Verify RelatedIPAddressNodeInput now exposes hfid in the GraphQL schema
  • Test creating a BGP session (or similar) with an IP address relationship referenced by HFID
  • Confirm existing from_pool and id based IP address references still work

🤖 Generated with Claude Code

RelatedIPAddressNodeInput was missing the hfid field, preventing IP
address relationships from being referenced by human-friendly ID.
Both RelatedNodeInput and RelatedIPPrefixNodeInput already had this
field.

Fixes #8574

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BeArchiTek BeArchiTek requested a review from a team as a code owner March 11, 2026 19:24
@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Mar 11, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3615b9d3-6b2c-4201-9630-8212ba8cf74b

📥 Commits

Reviewing files that changed from the base of the PR and between b44572e and 832fd82.

📒 Files selected for processing (2)
  • backend/tests/component/graphql/mutations/test_ipam.py
  • frontend/app/src/shared/api/graphql/graphql-env.d.ts

Walkthrough

The pull request adds an optional hfid field (List of String, not required) to the RelatedIPAddressNodeInput and RelatedIPPrefixNodeInput GraphQL input types. The backend GraphQL input class for related IP addresses was updated, the GraphQL schema was extended accordingly, TypeScript introspection types were adjusted, and a component test and fixture were added to exercise IP address relationship resolution via HFID. A changelog entry documenting the addition was included.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding the missing hfid field to RelatedIPAddressNodeInput, which directly addresses the core objective.
Description check ✅ Passed The description covers key aspects including the problem statement, solution, and testing approach, though the test plan section uses unchecked checkboxes.
Linked Issues check ✅ Passed The changes fully address issue #8574: adding hfid field to RelatedIPAddressNodeInput, updating the GraphQL schema, and including a test for HFID-based IP address relationships.
Out of Scope Changes check ✅ Passed All changes are directly related to adding the hfid field to RelatedIPAddressNodeInput as specified in issue #8574; no extraneous modifications detected.

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

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 11, 2026

Merging this PR will improve performance by 38.69%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 12 improved benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_schemabranch_process 1,026.1 ms 784.5 ms +30.8%
test_relationshipmanager_getpeer 155.9 µs 132.5 µs +17.68%
test_get_menu 245.4 ms 188 ms +30.5%
test_query_rel_one 662.3 ms 500.5 ms +32.32%
test_schemabranch_duplicate 7.2 ms 5.5 ms +31.49%
test_query_rel_many 693.3 ms 522.9 ms +32.61%
test_query_one_model 464.3 ms 352.8 ms +31.62%
test_get_schema 323.6 ms 247.6 ms +30.72%
test_graphql_generate_schema 516.1 ms 372.1 ms +38.69%
test_load_node_to_db_node_schema 66.2 ms 51.5 ms +28.64%
test_nodemanager_querypeers 1.5 ms 1.2 ms +21.9%
test_base_schema_duplicate_CoreProposedChange 2.1 ms 1.7 ms +22.92%

Comparing fix/8574-ip-address-hfid-input-v2 (4b2e759) with stable (c396f66)1

Open in CodSpeed

Footnotes

  1. No successful run was found on stable (916f5b5) during the generation of this report, so c396f66 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Contributor

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/infrahub/graphql/types/attribute.py`:
- Line 42: Add a regression test that exercises creating and updating an
IP-address relationship via the new hfid field: write a test that calls the
IpamIPAddress mutation using RelatedIPAddressNodeInput with hfid set (e.g.,
passing an HFID that resolves to an IpamIPAddress and asserting ip_prefix is
set), then also exercise the existing id and from_pool paths to ensure they
still work (create/update via id and via from_pool and assert the same resulting
ip_prefix/relationship). Target test helpers that construct GraphQL inputs for
RelatedIPAddressNodeInput and calls to IpamIPAddress mutation, and include
assertions verifying the relationship was created/updated and no regressions on
id/from_pool behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2353329-cacc-43bd-bd6a-4b6a942bb12f

📥 Commits

Reviewing files that changed from the base of the PR and between aad3175 and b44572e.

📒 Files selected for processing (3)
  • backend/infrahub/graphql/types/attribute.py
  • changelog/+8574-ip-address-hfid.fixed.md
  • schema/schema.graphql

BeArchiTek and others added 2 commits March 11, 2026 21:55
Adds a component test that verifies a relationship targeting
IpamIPAddress can be referenced by human-friendly ID in a GraphQL
create mutation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BeArchiTek BeArchiTek requested a review from a team as a code owner March 11, 2026 20:55
@github-actions github-actions bot added the group/frontend Issue related to the frontend (React) label Mar 11, 2026
@BeArchiTek BeArchiTek self-assigned this Mar 11, 2026
Comment on lines +1388 to +1407
"nodes": [
{
"name": "IPPrefix",
"namespace": "Ipam",
"default_filter": "prefix__value",
"order_by": ["prefix__value"],
"display_labels": ["prefix__value"],
"branch": "aware",
"inherit_from": [InfrahubKind.IPPREFIX],
},
{
"name": "IPAddress",
"namespace": "Ipam",
"default_filter": "address__value",
"order_by": ["address__value"],
"display_labels": ["address__value"],
"human_friendly_id": ["address__value"],
"branch": "aware",
"inherit_from": [InfrahubKind.IPADDRESS],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's an existing ipam_schema fixture in component/conftest.py that you could copy and update to have an HFID instead of defining the whole schema here, which would reduce the size of the test. also, looks like IpamIPPrefix is not actually used

assert not result.errors
assert result.data
assert result.data["TestDeviceCreate"]["ok"]
assert result.data["TestDeviceCreate"]["object"]["primary_ip"]["node"]["address"]["value"] == "10.0.0.1/32"
Copy link
Contributor

Choose a reason for hiding this comment

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

it's also good to test retrieving the new object from the database using NodeManager and confirming the data to ensure that the changes make it all the way to the db. in this test it is possible that the changes are just made in the mutation and discarded before actually being saved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent) group/frontend Issue related to the frontend (React)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RelatedIPAddressNodeInput missing hfid field

2 participants