Skip to content

fix: Pipeline TypeError: can only concatenate list (not "NoneType") to list Using Sou (#5518)#17

Closed
aviruthen wants to merge 1 commit intomasterfrom
fix/pipeline-typeerror-can-only-concatenate-list-not-5518
Closed

fix: Pipeline TypeError: can only concatenate list (not "NoneType") to list Using Sou (#5518)#17
aviruthen wants to merge 1 commit intomasterfrom
fix/pipeline-typeerror-can-only-concatenate-list-not-5518

Conversation

@aviruthen
Copy link
Copy Markdown
Owner

Description

Fix TypeError when using SourceCode without requirements in Pipeline

Fixes aws#5518

Problem

When creating a Pipeline with a TrainingStep that uses a SourceCode object without setting requirements, the pipeline build fails with:

TypeError: can only concatenate list (not 'NoneType') to list

This occurs because source_code.requirements is None when not explicitly set, and this None value gets passed as the dependencies parameter to get_training_code_hash(), which then attempts to use it in a list concatenation.

Solution

  • In get_code_hash(): Normalize source_code.requirements using or None to ensure any falsy value (empty string, empty list, None) is consistently treated as None
  • In get_training_code_hash(): Add a defensive dependencies = dependencies or None guard at the top of the function body to handle any falsy value passed by callers, ensuring the existing if dependencies: guards work correctly regardless of the input type

Testing

Added unit tests to verify:

  • get_training_code_hash() works correctly when dependencies is None
  • get_training_code_hash() works correctly when dependencies is an empty string
  • get_training_code_hash() works correctly with both source_dir and entry_point paths when dependencies are not provided

Related Issue

Fixes aws#5518

Changes Made

The bug occurs in get_code_hash() in sagemaker-core/src/sagemaker/core/workflow/utilities.py. When a TrainingStep uses a SourceCode object without setting requirements, source_code.requirements is None. This None value is passed as the dependencies parameter to get_training_code_hash(). While the current code in the repo has if dependencies: guards before concatenating, the user's version (3.3.1) hits [source_dir] + dependencies where dependencies is None, causing TypeError: can only concatenate list (not 'NoneType') to list. The fix should add a defensive or None coercion in get_code_hash() when extracting requirements from source_code, and also add an explicit None/empty-list guard at the top of get_training_code_hash() to make it robust regardless of caller behavior.

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 92%
  • 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)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Can you omit the change to requirements (source_code.requirements or None)? Our team is okay not having this change

@aviruthen aviruthen closed this Mar 20, 2026
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.

Pipeline TypeError: can only concatenate list (not "NoneType") to list Using SourceCode

1 participant