Skip to content

Conversation

@ajtmccarty
Copy link
Contributor

@ajtmccarty ajtmccarty commented Aug 12, 2025

fixes #7022

depends on opsmill/infrahub-sdk-python#494

fixed bug in deep_merge_dict (used by generate_fields_for_display_label) that prevented merging a dictionary like {"name": None} with {"name": {"value": None}}

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue where display labels could not include the same attribute expressed in different forms (e.g., “name” and “name__value”), ensuring correct rendering.
  • Tests
    • Added unit coverage validating display label generation with inherited and generic schema attributes.
  • Documentation
    • Added a changelog entry describing the display label rendering fix.
  • Chores
    • Updated Python SDK submodule reference to the latest tracked commit.

@ajtmccarty ajtmccarty requested a review from a team as a code owner August 12, 2025 21:43
@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Aug 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Walkthrough

Adds a unit test covering GenericSchema integration with display label field generation, a changelog entry documenting the display-label bug fix, and updates the tracked commit of the python_sdk submodule.

Changes

Cohort / File(s) Summary
Tests: Schema display label generation
backend/tests/unit/core/test_schema.py
Adds test_node_schema_generate_fields_for_display_label_with_generic to validate generate_fields_for_display_label with a GenericSchema and inheriting NodeSchemas; adds imports for Branch and GenericSchema and a typed default_branch parameter.
Changelog entry
changelog/7022.fixed.md
Adds changelog note describing fix for display label rendering when same attribute appears in different forms (e.g., name vs name__value).
Submodule update
python_sdk
Updates the tracked commit for the python_sdk submodule (submodule reference changed to a newer commit).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix display label conflict when nodes sharing the same generic use both ["name"] and ["name__value"] in display_labels (#7022) Test added covers GenericSchema inheritance but does not demonstrate or modify behavior for the specific name vs name__value conflict; no core display-label implementation changes present.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Update python_sdk submodule reference (python_sdk) Submodule commit bump is a dependency/metadata update unrelated to the API Server/GraphQL display-label bug described in #7022.

Possibly related PRs


📜 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 b697ce4 and a41f418.

📒 Files selected for processing (1)
  • python_sdk (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • python_sdk
⏰ 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). (3)
  • GitHub Check: E2E-testing-version-upgrade / From 1.1.0
  • GitHub Check: validate-generated-documentation
  • GitHub Check: documentation
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ajtm-08122025-display-label-def

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (2)
changelog/7022.fixed.md (1)

1-1: Polish changelog fragment for clarity, consistency, and punctuation

Use code formatting for the API field name, be explicit about “node schemas inheriting from the same generic,” and end the sentence with a period.

-Fix bug in display label rendering that prevented schemas from defining display labels with the same attribute names in different ways (`name` vs `name__value`, for example)
+Fix `display_label` retrieval failing when node schemas inheriting from the same generic define the same attribute in both forms (`name` and `name__value`).
backend/tests/unit/core/test_schema.py (1)

118-118: Add return type and a concise docstring per guidelines

Per the project’s Python guidelines, add a return type hint and a short Google-style docstring.

Apply this diff:

-async def test_node_schema_generate_fields_for_display_label_with_generic(default_branch: Branch):
+async def test_node_schema_generate_fields_for_display_label_with_generic(default_branch: Branch) -> None:
+    """Validate merging of display label fields across generic inheritors.
+
+    Args:
+        default_branch: Branch fixture used to scope a temporary SchemaBranch.
+
+    Returns:
+        None
+    """
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93bf72a and b697ce4.

📒 Files selected for processing (3)
  • backend/tests/unit/core/test_schema.py (3 hunks)
  • changelog/7022.fixed.md (1 hunks)
  • python_sdk (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{md,mdx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{md,mdx}: Lint markdown files using markdownlint with .markdownlint.yaml configuration
Documentation content must be accurate, reflect the latest version of Infrahub, and have correct markdown formatting, spelling, and grammar

Files:

  • changelog/7022.fixed.md
backend/tests/**/*

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Place backend tests in backend/tests/

Files:

  • backend/tests/unit/core/test_schema.py
backend/**/*

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Run backend tests with pytest or via invoke tasks

Files:

  • backend/tests/unit/core/test_schema.py
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: Use type hints for all function parameters and return values in Python files
Use async/await whenever possible in Python code
Use async def for asynchronous functions in Python
Use await for asynchronous calls in Python
Use Pydantic models for dataclasses in Python
All Python functions must have docstrings
Always use triple quotes (""") for docstrings in Python
Follow Google-style docstring format in Python files
Include sections in Python docstrings when applicable: Brief one-line description, Detailed description, Args/Parameters (without typing), Returns, Raises, Examples
Use ruff and mypy for type checking and validations in Python files
Format all Python files using poetry run invoke format
Validate Python formatting and linting using poetry run invoke lint

Files:

  • backend/tests/unit/core/test_schema.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). (10)
  • GitHub Check: E2E-testing-version-upgrade / From 1.1.0
  • GitHub Check: documentation
  • GitHub Check: validate-generated-documentation
  • GitHub Check: E2E-testing-invoke-demo-start
  • GitHub Check: backend-docker-integration
  • GitHub Check: backend-benchmark
  • GitHub Check: E2E-testing-playwright
  • GitHub Check: backend-tests-functional
  • GitHub Check: backend-tests-unit
  • GitHub Check: backend-tests-integration
🔇 Additional comments (5)
python_sdk (1)

1-1: ✅ Submodule bump verified

  • python_sdk is pinned to commit d5ac4abfb3fa7889a366b27a31c579a4b301d078 in the superproject tree.
  • Submodule HEAD at that commit shows the “handle None comparison in deep_merge_dict” change, which matches the fix from opsmill/infrahub-sdk-python#494.
  • Working tree is clean with no local modifications in the submodule.

No further action required.

backend/tests/unit/core/test_schema.py (4)

7-7: Importing Branch for fixture typing is correct

The import is necessary for the default_branch: Branch annotation and keeps mypy happy.


20-20: Importing GenericSchema is appropriate

Required for constructing the generic used in the new test; looks good.


148-149: Assertion matches the intended bugfix behavior

Asserting the union with normalized property access ({'name': {'value': None}}) ensures the deep-merge regression is caught. Good coverage for the None-vs-dict merge case.


145-147: Verify default_branch fixture isolation and consider local SchemaBranch

The test under backend/tests/unit/core/test_schema.py currently mutates the global registry:

registry.schema.register_schema(schema=schema_root, branch=default_branch.name)
schema_branch = registry.schema.get_schema_branch(name=default_branch.name)

Mutating registry.schema can leak state across tests. Please verify:

  • Where and how the default_branch fixture is implemented (e.g. in backend/tests/conftest.py or a plugin).
  • That it resets registry.schema._branches and registry.schema._cache (or the entire manager) between test runs.

If the fixture does not clear the registry, replace the global mutation with a local SchemaBranch to isolate state:

- registry.schema.register_schema(schema=schema_root, branch=default_branch.name)
- schema_branch = registry.schema.get_schema_branch(name=default_branch.name)
+ schema_branch = SchemaBranch(cache={}, name=default_branch.name)
+ schema_branch.load_schema(schema=schema_root)

This ensures the test only affects its own SchemaBranch and avoids global side-effects.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 12, 2025

CodSpeed Performance Report

Merging #7023 will improve performances by 21.8%

Comparing ajtm-08122025-display-label-def (a41f418) with stable (0bc4c13)

Summary

⚡ 1 improvements
✅ 9 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
test_base_schema_duplicate_CoreProposedChange 2.2 ms 1.8 ms +21.8%

@ajtmccarty ajtmccarty merged commit ba92fe0 into stable Aug 13, 2025
39 checks passed
@ajtmccarty ajtmccarty deleted the ajtm-08122025-display-label-def branch August 13, 2025 16:33
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: display labels break if nodes with the same generic use ["name"] and ["name__value"] in definition

3 participants