SageMaker ModelPackageSummary structure requires ModelPackageName even when AWS API doesn't return it
Describe the bug
In the ModelPackageSummary structure located https://github.com/boto/botocore/blob/develop/botocore/data/sagemaker/2017-07-24/service-2.json#L25291-L25334, the ModelPackageName is marked as a required member, however this is not the case for the SageMaker API response for model packages that are part of the SageMaker model registry. I noticed this issue when I tried to create a Stubber that returns a response for ListModelPackages: when copying the same response as returned by the AWS SageMaker ListModelPackages API to the Stubber service response, I got an unexpected validation error.
I first contacted AWS via Premium support, and they informed me that this is the expected API behaviour when listing model packages in a model registry model package group, in that case the response will only include the ModelPackageArn as identifier, but not the ModelPackageName:
Please know that the SageMaker Service Team informed me this is the expected behaviour, and confirmed that versioned Model Packages attached to a ModelGroup don’t have a “ModelPackageName”, as they are identified by their "ModelPackageArn": 'arn:aws:sagemaker:
: :model-package/<ModelPackageGroupName>/<Version>'
Expected Behavior
ModelPackageName member should not be required for ModelPackageSummary entities that belong to a versioned model registry model package group, as par the API response.
Current Behavior
ModelPackageName member is required in the ModelPackageSummary even for versioned model registry model package groups, which results in a validation error when copying a SageMaker API response without modification from the ListModelPackages method to a botocore Stubber that mocks the response the same ListModelPackages operation.
Reproduction Steps
import boto3
from botocore import stub
sagemaker = boto3.client("sagemaker")
with stub.Stubber(sagemaker) as stubber:
stubber.add_response(
"list_model_packages",
{
"ModelPackageSummaryList": [
{
"ModelPackageGroupName": "some-mock-model",
"ModelPackageVersion": 1,
"ModelPackageArn": "arn:aws:sagemaker:mock-region-1:123456789:model-package/some-mock-model/1",
"ModelPackageDescription": "Foo",
"CreationTime": "2023-09-19T12:02:20.199000+00:00",
"ModelPackageStatus": "Completed",
"ModelApprovalStatus": "Approved",
},
]
},
)
Possible Solution
Make the ModelPackageName optional or change the SageMaker API to always return the attribute regardless of whether it is from a versioned model package group or not.
Additional Information/Context
No response
SDK version used
boto3==1.28.54, botocore==1.31.54
Environment details (OS name and version, etc.)
Amazon Linux release 2 (Karoo)
If the response from ListModelPackages does not return a required field, it shouldn't be validating. And yet it is.
This is a service side problem.
Checking in, I noticed that the boto3/botocore versions originally reported here are quite old (boto3==1.28.54, botocore==1.31.54). Can you confirm if this is still an issue in the latest version of Boto3? The latest version is 1.34.151. We cannot control what the SageMaker API returns, and if that team confirmed that this is the expected behavior, then I don't think there's anything we can do here.