fix(core): enforce correct kind on core resource models - #1296
Merged
Conversation
christian-pinto
previously approved these changes
Jul 28, 2026
AlessandroPomponio
enabled auto-merge
July 28, 2026 08:56
AlessandroPomponio
force-pushed
the
ap_1294_ensure_resource_kind_is_correct
branch
from
July 28, 2026 12:02
6f522d5 to
aa76e0f
Compare
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
AlessandroPomponio
force-pushed
the
ap_1294_ensure_resource_kind_is_correct
branch
from
July 28, 2026 13:14
a6645ef to
7b6d05a
Compare
christian-pinto
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enforces that each core resource model only accepts its own
kindvalue at validation time. Previously, pydantic would silently accept any validCoreResourceKindsvalue for thekindfield of any resource model; a mismatched kind could be deserialized without error. This change locks each model'skindfield to aLiteralof its specific enum member, so passing the wrong kind now raises aValidationError.High-level Changes
CoreResourceKindsnow inherits fromstrin addition toenum.Enum, enablingLiteralconstraints on enum members.kindfield on all five core resource models (DiscoverySpaceResource,OperationResource,SampleStoreResource,ActuatorConfigurationResource,DataContainerResource) is narrowed from the broadCoreResourceKindstype toLiteral[CoreResourceKinds.<SPECIFIC_VALUE>].ACTUATOR) is removed fromCoreResourceKinds.kindraises apydantic.ValidationError.Impact
Stricter model validation across all core resource types. Any code that previously constructed or deserialized a resource with an incorrect
kindvalue will now fail fast with a clear validation error instead of producing a silently malformed object. No API or schema changes for correct usage.