Skip to content

Conversation

@minitriga
Copy link
Contributor

@minitriga minitriga commented Nov 12, 2025

Fixes: #624

Summary by CodeRabbit

  • Bug Fixes

    • Fixed nested object template range expansion so per-item embedded parameters are respected when creating related objects, ensuring parameter overrides apply correctly and validation/expansion behave consistently.
  • Tests

    • Added tests for parameter handling in nested objects: top-level, missing, empty, and invalid (non-dictionary) parameter cases to prevent regressions.

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

The change forwards the object's parameters when creating nodes (parameters=self.parameters) and, for related-object creation paths, sources per-item parameters from the related entry (InfrahubObjectParameters(**value["parameters"]) or None) instead of reusing the parent's parameters. Tests add fixtures and cases covering missing, empty, and non-dict parameters, asserting that empty/missing parameters produce an expand_range attribute while non-dict parameters raise ValidationError.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing a bug with nested object template range expansion, which directly matches the core issue being addressed.
Linked Issues check ✅ Passed The PR implements the required fix for nested object range expansion by modifying parameter handling in infrahub_sdk/spec/object.py to use per-relationship parameter sourcing from embedded data.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the nested object template range expansion issue: modifications to parameter handling, a changelog entry, and comprehensive test coverage.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch atg-20251112-624

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e48d4f9 and 7ead841.

📒 Files selected for processing (1)
  • infrahub_sdk/spec/object.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • infrahub_sdk/spec/object.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: documentation
  • GitHub Check: Cloudflare Pages

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 Nov 12, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7ead841
Status: ✅  Deploy successful!
Preview URL: https://30b1c1bf.infrahub-sdk-python.pages.dev
Branch Preview URL: https://atg-20251112-624.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@           Coverage Diff           @@
##           stable     #625   +/-   ##
=======================================
  Coverage   75.46%   75.46%           
=======================================
  Files         113      113           
  Lines        9512     9512           
  Branches     1893     1893           
=======================================
  Hits         7178     7178           
+ Misses       1834     1833    -1     
- Partials      500      501    +1     
Flag Coverage Δ
integration-tests 34.90% <ø> (ø)
python-3.10 48.76% <ø> (+0.02%) ⬆️
python-3.11 48.76% <ø> (ø)
python-3.12 48.74% <ø> (ø)
python-3.13 48.74% <ø> (ø)
python-3.9 47.46% <ø> (ø)
python-filler-3.12 24.29% <ø> (ø)

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

Files with missing lines Coverage Δ
infrahub_sdk/spec/object.py 84.79% <ø> (+0.67%) ⬆️

... and 1 file with indirect coverage changes

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

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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 709cbd2 and 1c0b643.

📒 Files selected for processing (3)
  • changelog/624.fixed.md (1 hunks)
  • infrahub_sdk/spec/object.py (2 hunks)
  • tests/unit/sdk/spec/test_object.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • infrahub_sdk/spec/object.py
  • tests/unit/sdk/spec/test_object.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place and write unit tests under tests/unit/ (isolated component tests)

Files:

  • tests/unit/sdk/spec/test_object.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use the custom pytest plugin (infrahub_sdk.pytest_plugin) fixtures for clients, configuration, and Infrahub-specific testing

Files:

  • tests/unit/sdk/spec/test_object.py
🧬 Code graph analysis (2)
infrahub_sdk/spec/object.py (1)
infrahub_sdk/spec/models.py (1)
  • InfrahubObjectParameters (6-7)
tests/unit/sdk/spec/test_object.py (3)
tests/unit/sdk/conftest.py (2)
  • client_with_schema_01 (1886-1888)
  • client (32-33)
infrahub_sdk/spec/object.py (4)
  • ObjectFile (634-662)
  • validate_format (179-198)
  • validate_format (655-659)
  • spec (638-644)
infrahub_sdk/exceptions.py (1)
  • ValidationError (117-129)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
changelog/624.fixed.md (1)

1-1: LGTM!

The changelog entry accurately documents the fix for nested object template range expansion.

infrahub_sdk/spec/object.py (1)

212-212: LGTM!

Correctly passes parameters to ensure top-level parameters flow through to node creation.

tests/unit/sdk/spec/test_object.py (2)

103-118: Good edge case coverage for parameter validation.

These fixtures properly test boundary conditions for parameter handling (non-dict and empty dict cases).


244-265: The review comment references a non-existent issue and unverified feature scope.

Issue #624 does not appear anywhere in the codebase—no references in code, tests, documentation, or changelogs. The suggestion to add nested relationship parameter inheritance tests is based on this phantom issue and lacks evidence that the feature is implemented or required. While parameters are passed through the validation chain and top-level expansion works, there is no code evidence that parameters propagate to nested relationships or that this behavior is currently tested. The existing four parameter tests only verify parameter accessibility, not nested inheritance.

If nested relationship parameter handling is genuinely needed, it should be tracked in a documented issue before test coverage is added. Otherwise, this represents speculative feature development without clear requirements.

Likely an incorrect or invalid review comment.

branch=branch,
default_schema_kind=default_schema_kind,
parameters=parameters,
parameters=InfrahubObjectParameters(**data[rel].get("parameters")) if "parameters" in data[rel] else None,
Copy link
Contributor

Choose a reason for hiding this comment

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

should the None be parameters here? I'm not sure how parameters passed into create_node are expected to behave in combination with parameters defined inside of data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If none is passed to the function it will create a new instance of InfrahubObjectParameters with parameters = parameters or InfrahubObjectParameters()

branch=branch,
default_schema_kind=default_schema_kind,
parameters=parameters,
parameters=InfrahubObjectParameters(**data[rel].get("parameters")) if "parameters" in data[rel] else None,
Copy link
Contributor

Choose a reason for hiding this comment

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

should the other calls to create_related_nodes in this method do something similar with overriding parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct. There is one other instance where range expansion is possible. I have added that but in the case where RelationshipDataFormat.ONE_OBJ is the relation there is no need for parameters as you cant expand into a cardinality of ONE.

…r initialization of InfrahubObjectParameters
@minitriga minitriga merged commit d66807f into stable Nov 13, 2025
20 checks passed
@minitriga minitriga deleted the atg-20251112-624 branch November 13, 2025 10:12
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.

bug: Object files broken

4 participants