Skip to content

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

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

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

Conversation

@aviruthen
Copy link
Copy Markdown
Owner

Description

Fix TypeError in Pipeline.upsert() when SourceCode.requirements is None

Fixes aws#5518

Problem

When calling pipeline.upsert() with a TrainingStep whose SourceCode object has no requirements set (defaults to None), a TypeError is raised because None is concatenated with a list in the code hashing utilities.

Specifically, get_processing_code_hash() has unguarded + dependencies list concatenation that fails when dependencies is None. While get_training_code_hash() already has if dependencies: guards, the processing code hash function did not have this protection.

Solution

Added defensive None-to-empty-list coercion (dependencies = dependencies or []) at the start of get_processing_code_hash() to prevent TypeError when dependencies is None and gets concatenated with a list.

The get_training_code_hash() function already handles None correctly via its existing if dependencies: conditional checks.

Testing

Added test cases to verify:

  • get_processing_code_hash() works correctly when dependencies=None (with and without source_dir)
  • get_training_code_hash() works correctly when dependencies=None (with source_dir and with entry_point only)

Related Issue

Fixes aws#5518

Changes Made

The bug occurs when pipeline.upsert() is called with a TrainingStep whose SourceCode object has no requirements set (defaults to None). In get_code_hash() within sagemaker-core/src/sagemaker/core/workflow/utilities.py, source_code.requirements (which is None) is passed as the dependencies parameter to get_training_code_hash(). While the current get_training_code_hash() has an if dependencies: guard, the issue traceback suggests an older version had hash_files_or_dirs([source_dir] + dependencies) without that guard. Additionally, get_processing_code_hash() still has unguarded + dependencies concatenation that would fail with None. The fix should ensure both functions defensively handle None dependencies, and that the caller in get_code_hash() normalizes None to a safe default before passing it along.

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.

Can you remove only the comment you left on the PR explaining why you added the code dependencies = dependences or []?

@aviruthen aviruthen closed this Mar 20, 2026
@aviruthen aviruthen deleted the fix/pipeline-typeerror-can-only-concatenate-list-not-5518-2 branch March 20, 2026 23:00
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