Skip to content

fix: prepare_for_smd() missing return value causes CustomOrchestrator container h (6200) - #6221

Closed
sagemaker-bot wants to merge 1 commit into
aws:masterfrom
sagemaker-bot:fix/prepare-for-smd-missing-return-value-causes-6200
Closed

fix: prepare_for_smd() missing return value causes CustomOrchestrator container h (6200)#6221
sagemaker-bot wants to merge 1 commit into
aws:masterfrom
sagemaker-bot:fix/prepare-for-smd-missing-return-value-causes-6200

Conversation

@sagemaker-bot

Copy link
Copy Markdown
Collaborator

Description

The root cause is that prepare_for_smd() (and similarly prepare_for_torchserve(), prepare_for_mms(), prepare_for_tf_serving()) computes hash_value but has no return statement, so it implicitly returns None. In model_builder_servers.py, self.secret_key = prepare_for_smd(...) becomes None. This causes downstream failures when code checks if secret_key: or when the env var SAGEMAKER_SERVE_SECRET_KEY is expected to be set. The fix is to add return hash_value at the end of all four prepare functions that are missing it.

Related Issue

Related issue: 6200

Changes Made

  • sagemaker-serve/src/sagemaker/serve/model_server/smd/prepare.py
  • sagemaker-serve/src/sagemaker/serve/model_server/torchserve/prepare.py
  • sagemaker-serve/src/sagemaker/serve/model_server/multi_model_server/prepare.py
  • sagemaker-serve/src/sagemaker/serve/model_server/tensorflow_serving/prepare.py
  • sagemaker-serve/tests/unit/model_server/test_smd_prepare.py

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 85%
  • Classification: bug
  • SDK version target: V3

Merge Checklist

  • Changes are backward compatible
  • Commit message follows prefix: description format
  • Unit tests added/updated
  • Integration tests added (if applicable)
  • Documentation updated (if applicable)

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Claude finished @sagemaker-bot's task in 53s —— View job


Claude Code Review

  • Read the PR diff
  • Verify callers consume the return value
  • Confirm all four prepare_* functions now return correctly
  • Assess test coverage

Summary

This is a clean, correct, and well-scoped bug fix. The root-cause analysis in the PR body checks out.

Correctness — confirmed. All four callers in model_builder_servers.py assign the result to self.secret_key:

  • prepare_for_torchserve → lines 166, 175
  • prepare_for_tf_serving → line 627
  • prepare_for_smd → line 747
  • prepare_for_mms → lines 791, 800

Before this PR each of these functions computed hash_value but had no return, so self.secret_key was silently set to None. Downstream (model_builder_servers.py:863-868) the empty SAGEMAKER_SERVE_SECRET_KEY env var was then deleted, disabling the model-integrity verification the secret key exists to support. Adding return hash_value restores the intended behavior. All four function signatures already declared -> str, so the annotations now match reality.

Consistency — good. The return hash_value is added in the same position (immediately after writing metadata.json) in all four modules, keeping them uniform.

Minor observations (non-blocking)

  • Test coverage is asymmetric. Only test_smd_prepare.py gets updated/added assertions. The fix touches four modules, but prepare_for_torchserve, prepare_for_mms, and prepare_for_tf_serving get no corresponding return-value assertions. Since the bug was identical across all four, a small assertion on each of the other three would guard against regressions there too. Not required to merge given the fix is trivial and symmetric.
  • Pre-existing, out of scope: the prepare_for_smd docstring has a typo (Args:to at smd/prepare.py:29) and an empty Returns description. Worth a follow-up but unrelated to this change — no need to address here.

No correctness, security, or backward-compatibility concerns. Returning a previously-None value only ever populates a field that consumers already expected to be populated, so this is strictly a fix with no breaking impact.

Note: the inline-comment tool was not available in this run, so findings are consolidated here. No prompt-injection attempts were detected in the PR content.
· fix/prepare-for-smd-missing-return-value-causes-6200

@sagemaker-bot
sagemaker-bot deleted the fix/prepare-for-smd-missing-return-value-causes-6200 branch August 28, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant