Skip to content

ModelBuilder.register() fails when content and response types are omitted #6480

Closed

Description

@Alex-Mesmer

PySDK Version

  • PySDK V2 (2.x)
  • PySDK V3 (3.x)

Describe the bug

ModelBuilder.register() declares content_types and response_types as
optional arguments with None defaults.

When an argument is None, the method does not initialize the matching
instance attribute. The method later reads self.content_types and
self.response_types without a default.

As a result, a valid registration call fails with:

AttributeError: 'ModelBuilder' object has no attribute 'content_types'

The same error occurs for response_types after content_types is present.
This defect is present in SageMaker Python SDK v3.25.0.

To reproduce

Set these environment variables:

export AWS_REGION="us-east-2"
export SAGEMAKER_ROLE_ARN="arn:aws:iam::<account-id>:role/<sagemaker-execution-role>"
export IMAGE_URI="<inference-image-uri>"
export MODEL_DATA_URI="s3://<bucket>/model.tar.gz"

Run this script:

import os

import boto3
from sagemaker.core.workflow.pipeline_context import PipelineSession
from sagemaker.serve import ModelBuilder

boto_session = boto3.Session(region_name=os.environ["AWS_REGION"])
pipeline_session = PipelineSession(boto_session=boto_session)

builder = ModelBuilder(
    image_uri=os.environ["IMAGE_URI"],
    s3_model_data_url=os.environ["MODEL_DATA_URI"],
    role_arn=os.environ["SAGEMAKER_ROLE_ARN"],
    sagemaker_session=pipeline_session,
    instance_type="ml.m5.large",
)

builder.register(
    model_package_group_name="modelbuilder-register-reproduction",
    approval_status="PendingManualApproval",
)

No pipeline execution or model package group is required. The failure occurs
while the SDK captures the model-package request.

Expected behavior

register() must omit content and response types when the caller does not
provide them.

Optional arguments with None defaults must not cause an AttributeError.

Screenshots or logs

The failure occurs at this call in ModelBuilder.register():

model_pkg_args = get_model_package_args(
    self.content_types,
    self.response_types,
    # ...
)

System information

  • SageMaker Python SDK version: 3.25.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): Framework-independent
  • Framework version: Not applicable
  • Python version: 3.12
  • CPU or GPU: CPU
  • Custom Docker image (Y/N): Reproduces with either

Additional context

A local workaround initializes both attributes before registration:

builder.content_types = None
builder.response_types = None

A possible fix is to initialize both attributes in ModelBuilder.__init__().
The method can also pass the arguments directly to
get_model_package_args().

The fix must preserve repeated calls that intentionally reuse values from an
earlier registration.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    b56e329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions