Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Oct 17, 2025

Displays schema deprecation warnings for infrahubctl when loading or checking schemas. Uses the new warnings key from opsmill/infrahub#7424.

Summary by CodeRabbit

  • New Features
    • Schema loading operations now display deprecation warnings to notify users of schema elements that are deprecated or will change in upcoming versions
    • Schema validation checks now show deprecation warnings to help users identify and address potential compatibility concerns early
    • Improved formatting and structure for schema warning messages across all operations

@coderabbitai
Copy link

coderabbitai bot commented Oct 17, 2025

Walkthrough

This pull request adds support for deprecation warnings in schema loading and checking operations. New warning-related models (SchemaWarningType, SchemaWarningKind, and SchemaWarning) are introduced to represent structured warning information. The SchemaLoadResponse model is updated to include a warnings field populated from server responses. The CLI schema commands are enhanced with a helper function to display warnings to users, and the load() and check() operations are modified to extract and render warnings alongside their existing functionality.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Process schema deprecation warnings" accurately captures the main objective of the changeset. The PR introduces new warning models, adds warnings to the schema load response, implements a helper function to display these warnings, and integrates warning display into the load() and check() methods. The title is concise, specific, and directly aligned with the stated PR objective to "display schema deprecation warnings when loading or checking schemas." A developer scanning the repository history would clearly understand that this PR adds functionality for handling schema deprecation warnings.
✨ 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-process-schema-deprecations

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 Oct 17, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7b7612d
Status: ✅  Deploy successful!
Preview URL: https://5584e1e4.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-process-schema-deprecati.infrahub-sdk-python.pages.dev

View logs

@ogenstad ogenstad force-pushed the pog-process-schema-deprecations branch 2 times, most recently from 73b5f9b to 11deff7 Compare October 17, 2025 09:16
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 53.33333% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/schema.py 20.00% 11 Missing and 1 partial ⚠️
infrahub_sdk/schema/__init__.py 86.66% 2 Missing ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #582      +/-   ##
====================================================
- Coverage             75.27%   75.25%   -0.03%     
====================================================
  Files                   108      108              
  Lines                  9375     9398      +23     
  Branches               1864     1868       +4     
====================================================
+ Hits                   7057     7072      +15     
- Misses                 1823     1830       +7     
- Partials                495      496       +1     
Flag Coverage Δ
integration-tests 34.93% <10.00%> (-0.07%) ⬇️
python-3.10 48.37% <13.33%> (-0.09%) ⬇️
python-3.11 48.39% <13.33%> (-0.09%) ⬇️
python-3.12 48.35% <13.33%> (-0.11%) ⬇️
python-3.13 48.37% <13.33%> (-0.07%) ⬇️
python-3.9 47.00% <13.33%> (-0.11%) ⬇️
python-filler-3.12 24.36% <40.00%> (+0.06%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/schema/__init__.py 67.14% <86.66%> (+0.78%) ⬆️
infrahub_sdk/ctl/schema.py 55.47% <20.00%> (-1.56%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad ogenstad force-pushed the pog-process-schema-deprecations branch from d687229 to 7b7612d Compare October 24, 2025 07:38
@ogenstad ogenstad marked this pull request as ready for review October 24, 2025 08:52
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 (2)
infrahub_sdk/ctl/schema.py (1)

203-207: Use console.print() for consistency.

Lines 204 and 206 use the built-in print() function, while the rest of the file consistently uses console.print() from Rich. This inconsistency could lead to formatting differences in output.

Apply this diff:

     if response == {"diff": {"added": {}, "changed": {}, "removed": {}}}:
-        print("No diff")
+        console.print("No diff")
     else:
-        print(yaml.safe_dump(data=response, indent=4))
+        console.print(yaml.safe_dump(data=response, indent=4))
infrahub_sdk/schema/__init__.py (1)

93-111: LGTM!

The warning model hierarchy is well-designed with proper Pydantic validation, clear field descriptions, and a useful display property for formatting. The structure is extensible for future warning types beyond deprecation.

Consider adding the new public models (SchemaWarningType, SchemaWarningKind, SchemaWarning) to the __all__ list (lines 51-67) for better API discoverability and consistency with other exported models.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dcc1db and 7b7612d.

📒 Files selected for processing (3)
  • changelog/+f6791a3d.added.md (1 hunks)
  • infrahub_sdk/ctl/schema.py (3 hunks)
  • infrahub_sdk/schema/__init__.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/schema/__init__.py
  • infrahub_sdk/ctl/schema.py
infrahub_sdk/ctl/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

infrahub_sdk/ctl/**/*.py: Build CLI commands with Typer
Organize and keep all CLI commands within infrahub_sdk/ctl/

Files:

  • infrahub_sdk/ctl/schema.py
🧬 Code graph analysis (1)
infrahub_sdk/ctl/schema.py (1)
infrahub_sdk/schema/__init__.py (2)
  • SchemaWarning (107-110)
  • display (102-104)
🔇 Additional comments (8)
changelog/+f6791a3d.added.md (1)

1-1: LGTM!

The changelog entry clearly documents the new deprecation warnings feature.

infrahub_sdk/ctl/schema.py (5)

17-17: LGTM!

The import correctly brings in the new SchemaWarning model for warning display functionality.


156-157: LGTM!

The warning display is correctly integrated after schema loading, leveraging the validated warnings from SchemaLoadResponse.


193-196: LGTM!

The defensive check with early return improves error handling when the check operation fails or returns no response.


197-202: LGTM!

The enhanced user feedback with per-schema validation messages and warning extraction improves the check command's output clarity.

Note: The manual validation at lines 200-202 using SchemaWarning.model_validate() could raise a ValidationError if the server returns malformed warning data. Consider whether wrapping this in a try-except would provide a better user experience, or if failing loudly is the preferred behavior for detecting server issues.


209-213: LGTM!

The helper function centralizes warning display logic with clear formatting. It correctly leverages the display property from SchemaWarningKind to format the kinds list.

infrahub_sdk/schema/__init__.py (2)

192-194: LGTM!

The defensive extraction pattern status.get("warnings") or [] safely handles missing or null warning data from the server, with Pydantic validating the structure automatically.


827-827: LGTM!

The warnings field is properly defined with Pydantic best practices, using default_factory=list for the mutable default and providing clear documentation.

Copy link
Contributor

@ajtmccarty ajtmccarty left a comment

Choose a reason for hiding this comment

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

early returns, small functions, very nice 👍

@ogenstad ogenstad merged commit 4c8134d into infrahub-develop Oct 24, 2025
20 checks passed
@ogenstad ogenstad deleted the pog-process-schema-deprecations branch October 24, 2025 14:38
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.

2 participants