Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Nov 13, 2025

Removed poetry.lock

Summary by CodeRabbit

  • Bug Fixes
    • Fixed nested object template range expansion to properly handle parameter propagation in deeply nested relationship chains. Previously, parameters were not correctly forwarded through multiple levels of nested templates, causing templates to fail when rendering complex nested object structures. This fix ensures reliable parameter handling and proper template rendering across all nesting levels.

minitriga and others added 3 commits November 13, 2025 10:12
* Add tests for parameter validation and fix nested object template range expansion

* Handle missing parameters in InfrahubObjectParameters initialization

* Refactor parameter handling in InfrahubObjectFileData to ensure proper initialization of InfrahubObjectParameters
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

This change releases version 1.15.1 with a fix for nested object template range expansion. The fix modifies parameter propagation in nested relationship processing within the ObjectFile implementation to use per-item parameters from nested data when available, rather than always forwarding outer parameters. The project version is updated in pyproject.toml, and test fixtures and test cases are added to validate parameter handling scenarios including top-level parameters, missing expand_range attributes, empty parameter dictionaries, and non-dictionary parameter types.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title describes a merge operation with conflict resolution, which aligns with the actual changes: version bump, bug fix implementation, and test additions across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 pog-develop-to-stable-20251113

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

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 811c047
Status: ✅  Deploy successful!
Preview URL: https://2b88b037.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-develop-to-stable-202511.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #629      +/-   ##
===========================================
+ Coverage    75.54%   75.56%   +0.02%     
===========================================
  Files          113      113              
  Lines         9512     9512              
  Branches      1448     1448              
===========================================
+ Hits          7186     7188       +2     
+ Misses        1839     1837       -2     
  Partials       487      487              
Flag Coverage Δ
integration-tests 34.95% <ø> (ø)
python-3.10 48.87% <ø> (+0.02%) ⬆️
python-3.11 48.87% <ø> (+0.02%) ⬆️
python-3.12 48.83% <ø> (ø)
python-3.13 48.83% <ø> (ø)
python-3.9 47.53% <ø> (+0.02%) ⬆️
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%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad ogenstad marked this pull request as ready for review November 13, 2025 12:06
@ogenstad ogenstad requested a review from a team November 13, 2025 12:06
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: 0

🧹 Nitpick comments (1)
tests/unit/sdk/spec/test_object.py (1)

244-265: Good parameter validation coverage, but consider adding nested scenario tests.

The tests effectively validate parameter handling at the top level and various edge cases. However, they don't directly test the core fix: nested parameter propagation in relationships (e.g., where a nested object in a relationship has its own parameters that should override parent parameters).

Consider adding a test that validates the actual bug fix scenario:

async def test_parameters_nested_override(client_with_schema_01: InfrahubClient) -> None:
    """Test that nested relationship objects can have their own parameters."""
    # Example: parent has expand_range=False, but nested child has expand_range=True
    data = {
        "apiVersion": "infrahub.app/v1",
        "kind": "Object",
        "spec": {
            "kind": "ParentKind",
            "parameters": {"expand_range": False},
            "data": [{
                "name": "Parent",
                "children": {
                    "parameters": {"expand_range": True},
                    "data": [{"name": "Child[1-3]"}]
                }
            }]
        }
    }
    obj = ObjectFile(location="some/path", content=data)
    await obj.validate_format(client=client_with_schema_01)
    # Validate that nested children were expanded despite parent's expand_range=False
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f532eac and 811c047.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • infrahub_sdk/spec/object.py (3 hunks)
  • pyproject.toml (1 hunks)
  • tests/unit/sdk/spec/test_object.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
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 (637-665)
  • validate_format (179-198)
  • validate_format (658-662)
  • spec (641-647)
infrahub_sdk/exceptions.py (1)
  • ValidationError (117-129)
infrahub_sdk/spec/object.py (1)
infrahub_sdk/spec/models.py (1)
  • InfrahubObjectParameters (6-7)
⏰ 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). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
pyproject.toml (1)

3-3: LGTM! Version bump aligns with the bug fix release.

The patch version increment from 1.15.0 to 1.15.1 is appropriate for the nested object template range expansion fix documented in the changelog.

CHANGELOG.md (1)

14-18: LGTM! Changelog entry is clear and well-formatted.

The release entry properly documents the fix for nested object template range expansion and includes appropriate issue reference.

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

103-118: LGTM! Well-structured test fixtures for parameter validation.

The new fixtures appropriately cover edge cases for parameter handling, including non-dict and empty dict scenarios.

infrahub_sdk/spec/object.py (3)

212-212: LGTM! Properly passes top-level parameters to node creation.

The addition of parameters=self.parameters ensures that top-level parameters are propagated to the node creation flow, which is essential for the parameter handling to work correctly.


473-476: LGTM! Correctly implements per-item parameter propagation for nested relationships.

The change from forwarding outer parameters to extracting per-item parameters from value.get("parameters") is the core fix for nested object template range expansion. This allows nested relationship objects to have their own independent parameter settings (e.g., expand_range).


514-517: LGTM! Consistent parameter extraction for remaining relationships.

The parameter extraction pattern matches the approach used in lines 473-476, ensuring consistent behavior across different relationship processing paths. The conditional check prevents errors when nested objects don't specify parameters.

@ogenstad ogenstad merged commit c0eb8a1 into develop Nov 14, 2025
20 checks passed
@ogenstad ogenstad deleted the pog-develop-to-stable-20251113 branch November 14, 2025 06:35
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.

4 participants