Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Oct 17, 2025

This PR adds the concept of returning deprecation warnings through the API endpoints when loading or checking a schema. The idea is to help users to determine when they are using deprecated features.

It will go together with this PR in the SDK repo: opsmill/infrahub-sdk-python#582

The change is quite simple, one thing I'm not completely sure of is the structure of the warning that currently looks like this:

class SchemaWarningType(Enum):
DEPRECATION = "deprecation"

class SchemaWarning(BaseModel):
type: SchemaWarningType = Field(..., description="The type of warning")
kind: str = Field(..., description="The kind impacted by the warning")
message: str = Field(..., description="The message that describes the warning")

I'm thinking that later we could add other warning types such as STRICT for when Infrahub isn't running in strict mode and we want to report back on those issues.

What I'm unsure of is the kind: str if we think that any future schema warning will always be tied to a kind, just now I can't think of other variations but it could just be that I'm missing it now. Any thoughts? We can always modify it later, but that might be a breaking change. I think it's fine as it is now, but not certain..

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Oct 17, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • stable
  • develop

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pog-add-schema-deprecation-warnings

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

CodSpeed Performance Report

Merging #7424 will not alter performance

Comparing pog-add-schema-deprecation-warnings (fd08dc5) with release-1.5 (d0b8988)

Summary

✅ 10 untouched

@ogenstad ogenstad force-pushed the pog-add-schema-deprecation-warnings branch from 39a6fc3 to a2e995a Compare October 17, 2025 15:01
@dgarros
Copy link
Collaborator

dgarros commented Oct 18, 2025

Great improvement
Regarding the format, in addition to the kind, I think it would be good to also report the complete path to the warning (or as details as possible). For example, if the issue is on an attribute we should be able to report kind & attribute etc ..
We have something similar for the error currently.

Also I don't think we should assume that a warning will always be associated with a single kind, I'm sure we'll find situations where a warning needs to be associated with multiple kinds or none at all. it would be good to ensure that the structure will support that.
we could return a list of paths, associated with a warning, this way we can have 0, 1 or many

@ogenstad
Copy link
Contributor Author

Also I don't think we should assume that a warning will always be associated with a single kind, I'm sure we'll find situations where a warning needs to be associated with multiple kinds or none at all. it would be good to ensure that the structure will support that. we could return a list of paths, associated with a warning, this way we can have 0, 1 or many

Yes that was the part I wasn't sure about from the description. I don't see any situation just now what kind of error it would be that wouldn't include a kind. Might be that kind should instead be a list of objects that can be empty and that attribute is an optional value within that context?

@ogenstad ogenstad changed the base branch from develop to release-1.5 October 23, 2025 11:15
@ogenstad ogenstad force-pushed the pog-add-schema-deprecation-warnings branch from a2e995a to c7933ec Compare October 23, 2025 11:29

class SchemaWarningKind(BaseModel):
kind: str = Field(..., description="The kind impacted by the warning")
attribute: str | None = Field(default=None, description="The attribute impacted by the warning")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would replace attribute with field since it could also be a relationship.
We are using field or element in a few places to represent either an attribute or a relationship

@ogenstad ogenstad force-pushed the pog-add-schema-deprecation-warnings branch 2 times, most recently from 92abff5 to 40281e5 Compare October 23, 2025 18:17
@ogenstad ogenstad marked this pull request as ready for review October 23, 2025 19:33
@ogenstad ogenstad requested a review from a team as a code owner October 23, 2025 19:33
@ogenstad ogenstad force-pushed the pog-add-schema-deprecation-warnings branch from 40281e5 to fd08dc5 Compare October 24, 2025 07:40
@ogenstad ogenstad merged commit d96360a into release-1.5 Oct 24, 2025
65 of 66 checks passed
@ogenstad ogenstad deleted the pog-add-schema-deprecation-warnings branch October 24, 2025 08:51
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.

2 participants