Conversation
…o list Using Sou (aws#5518)
aviruthen
commented
Mar 20, 2026
Owner
Author
There was a problem hiding this comment.
Nice work! Can you omit the change to requirements (source_code.requirements or None)? Our team is okay not having this change
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.
Description
Fix TypeError when using SourceCode without requirements in Pipeline
Fixes aws#5518
Problem
When creating a
Pipelinewith aTrainingStepthat uses aSourceCodeobject without settingrequirements, the pipeline build fails with:This occurs because
source_code.requirementsisNonewhen not explicitly set, and thisNonevalue gets passed as thedependenciesparameter toget_training_code_hash(), which then attempts to use it in a list concatenation.Solution
get_code_hash(): Normalizesource_code.requirementsusingor Noneto ensure any falsy value (empty string, empty list,None) is consistently treated asNoneget_training_code_hash(): Add a defensivedependencies = dependencies or Noneguard at the top of the function body to handle any falsy value passed by callers, ensuring the existingif dependencies:guards work correctly regardless of the input typeTesting
Added unit tests to verify:
get_training_code_hash()works correctly whendependenciesisNoneget_training_code_hash()works correctly whendependenciesis an empty stringget_training_code_hash()works correctly with bothsource_dirandentry_pointpaths when dependencies are not providedRelated Issue
Fixes aws#5518
Changes Made
The bug occurs in
get_code_hash()insagemaker-core/src/sagemaker/core/workflow/utilities.py. When aTrainingStepuses aSourceCodeobject without settingrequirements,source_code.requirementsisNone. ThisNonevalue is passed as thedependenciesparameter toget_training_code_hash(). While the current code in the repo hasif dependencies:guards before concatenating, the user's version (3.3.1) hits[source_dir] + dependencieswheredependenciesisNone, causingTypeError: can only concatenate list (not 'NoneType') to list. The fix should add a defensiveor Nonecoercion inget_code_hash()when extractingrequirementsfromsource_code, and also add an explicitNone/empty-list guard at the top ofget_training_code_hash()to make it robust regardless of caller behavior.AI-Generated PR
This PR was automatically generated by the PySDK Issue Agent.
Merge Checklist
prefix: descriptionformat