Skip to content

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

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)#21
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 when SourceCode.requirements is None in Pipeline

Fixes a TypeError that occurs when using SourceCode without setting requirements (which defaults to None) in a Pipeline context.

Problem

When SourceCode.requirements is None and a TrainingStep is compiled in a pipeline, the None value is passed as the dependencies parameter to get_training_code_hash(). While the function has if dependencies: guards in some branches, the get_processing_code_hash() function performs list concatenation ([source_dir] + dependencies) without checking if dependencies is None, which would cause a TypeError: 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 dependencies is always a list, preventing TypeError from list concatenation with None and providing defense-in-depth even where existing if dependencies: guards exist.

Testing

Added test cases:

  • test_get_training_code_hash_with_none_dependencies_source_dir — source_dir with dependencies=None
  • test_get_training_code_hash_with_entry_point_only_and_none_dependencies — entry_point only with dependencies=None
  • test_get_processing_code_hash_with_none_dependencies_source_dir — source_dir with dependencies=None
  • test_get_processing_code_hash_with_none_dependencies_code_only — code only with dependencies=None

Related Issue

Fixes aws#5518

Changes Made

The bug occurs when SourceCode.requirements is not set (defaults to None), which gets passed as the dependencies parameter to get_training_code_hash() in sagemaker-core/src/sagemaker/core/workflow/utilities.py. The current code already has if dependencies: guards in get_training_code_hash, but the defensive fix of defaulting None to [] at the start of the function is more robust and prevents regressions. Additionally, get_processing_code_hash has the same latent bug where it performs [source_dir] + dependencies / [code] + dependencies without checking if dependencies is None. Both functions should default None dependencies to an empty list at the start of the function body.

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 add a comment over your source code changes explaining why you default to []?

@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:33
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