Skip to content

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

Closed
aviruthen wants to merge 2 commits 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)#18
aviruthen wants to merge 2 commits 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 code hash computation

Problem

When creating a TrainingStep in a pipeline with a ModelTrainer whose SourceCode.requirements is None (the default), the pipeline build could fail with:

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

This occurred because get_processing_code_hash() concatenates the dependencies parameter directly with a list without first checking if it's None.

Root Cause

In get_processing_code_hash(), the dependencies parameter is concatenated with lists (e.g., [source_dir] + dependencies) without a guard against None values. While get_training_code_hash() already has if dependencies: guards, get_processing_code_hash() did not.

Fix

  • Added dependencies = dependencies or [] at the top of get_processing_code_hash() to defensively normalize None to an empty list before any list concatenation occurs.
  • Added comprehensive test cases covering None dependencies for both get_processing_code_hash() and get_training_code_hash().

Testing

  • Added test_get_processing_code_hash_with_none_dependencies - verifies no TypeError with source_dir and None dependencies
  • Added test_get_processing_code_hash_code_only_with_none_dependencies - verifies no TypeError with code only and None dependencies
  • Added test_get_training_code_hash_with_none_dependencies_source_dir - verifies None dependencies with source_dir
  • Added test_get_training_code_hash_with_none_dependencies_entry_point_only - verifies None dependencies with entry_point only

Related Issue

Fixes aws#5518

Changes Made

The bug occurs when SourceCode.requirements is None (not set by the user) and is passed as the dependencies parameter to get_training_code_hash(). While the current code in the repository has if dependencies: guards in get_training_code_hash(), the issue reporter's version (3.3.1) encounters a TypeError: can only concatenate list (not 'NoneType') to list at the hash_files_or_dirs([source_dir] + dependencies) call. The fix should be applied in two places: (1) in get_code_hash() to defensively pass None requirements as empty/no-dependency, and (2) in get_processing_code_hash() which has the same latent bug where dependencies could theoretically be None but is concatenated without a guard.

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 90%
  • 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 small comment explaining why you are adding a default value of [] if dependencies is None?

@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 22:49
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