Skip to content

fix(core): enforce correct kind on core resource models - #1296

Merged
AlessandroPomponio merged 1 commit into
mainfrom
ap_1294_ensure_resource_kind_is_correct
Jul 28, 2026
Merged

fix(core): enforce correct kind on core resource models#1296
AlessandroPomponio merged 1 commit into
mainfrom
ap_1294_ensure_resource_kind_is_correct

Conversation

@AlessandroPomponio

@AlessandroPomponio AlessandroPomponio commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enforces that each core resource model only accepts its own kind value at validation time. Previously, pydantic would silently accept any valid CoreResourceKinds value for the kind field of any resource model; a mismatched kind could be deserialized without error. This change locks each model's kind field to a Literal of its specific enum member, so passing the wrong kind now raises a ValidationError.

High-level Changes

  • CoreResourceKinds now inherits from str in addition to enum.Enum, enabling Literal constraints on enum members.
  • The kind field on all five core resource models (DiscoverySpaceResource, OperationResource, SampleStoreResource, ActuatorConfigurationResource, DataContainerResource) is narrowed from the broad CoreResourceKinds type to Literal[CoreResourceKinds.<SPECIFIC_VALUE>].
  • A commented-out dead enum member (ACTUATOR) is removed from CoreResourceKinds.
  • New tests are added for each affected resource type to assert that providing a mismatched kind raises a pydantic.ValidationError.

Impact

Stricter model validation across all core resource types. Any code that previously constructed or deserialized a resource with an incorrect kind value will now fail fast with a clear validation error instead of producing a silently malformed object. No API or schema changes for correct usage.


AI Disclosure: The code and this PR description were generated using IBM Bob and reviewed manually.

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
@AlessandroPomponio
AlessandroPomponio force-pushed the ap_1294_ensure_resource_kind_is_correct branch from a6645ef to 7b6d05a Compare July 28, 2026 13:14
@AlessandroPomponio
AlessandroPomponio added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit 1264be0 Jul 28, 2026
18 checks passed
@AlessandroPomponio
AlessandroPomponio deleted the ap_1294_ensure_resource_kind_is_correct branch July 28, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Enables CI integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): resource classes do not enforce their own kind at construction time

2 participants