Conversation
…o list Using Sou (aws#5518)
aviruthen
commented
Mar 20, 2026
Owner
Author
There was a problem hiding this comment.
Can you add a comment over your source code changes explaining why you default to []?
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 SourceCode.requirements is None in Pipeline
Fixes a
TypeErrorthat occurs when usingSourceCodewithout settingrequirements(which defaults toNone) in a Pipeline context.Problem
When
SourceCode.requirementsisNoneand aTrainingStepis compiled in a pipeline, theNonevalue is passed as thedependenciesparameter toget_training_code_hash(). While the function hasif dependencies:guards in some branches, theget_processing_code_hash()function performs list concatenation ([source_dir] + dependencies) without checking ifdependenciesisNone, which would cause aTypeError: can only concatenate list (not "NoneType") to list.Fix
Added defensive
dependencies = dependencies or []at the start of both:get_processing_code_hash()get_training_code_hash()This ensures
dependenciesis always a list, preventingTypeErrorfrom list concatenation withNoneand providing defense-in-depth even where existingif dependencies:guards exist.Testing
Added test cases:
test_get_training_code_hash_with_none_dependencies_source_dir— source_dir withdependencies=Nonetest_get_training_code_hash_with_entry_point_only_and_none_dependencies— entry_point only withdependencies=Nonetest_get_processing_code_hash_with_none_dependencies_source_dir— source_dir withdependencies=Nonetest_get_processing_code_hash_with_none_dependencies_code_only— code only withdependencies=NoneRelated Issue
Fixes aws#5518
Changes Made
The bug occurs when
SourceCode.requirementsis not set (defaults toNone), which gets passed as thedependenciesparameter toget_training_code_hash()insagemaker-core/src/sagemaker/core/workflow/utilities.py. The current code already hasif dependencies:guards inget_training_code_hash, but the defensive fix of defaultingNoneto[]at the start of the function is more robust and prevents regressions. Additionally,get_processing_code_hashhas the same latent bug where it performs[source_dir] + dependencies/[code] + dependencieswithout checking ifdependenciesis None. Both functions should defaultNonedependencies to an empty list at the start of the function body.AI-Generated PR
This PR was automatically generated by the PySDK Issue Agent.
Merge Checklist
prefix: descriptionformat