Skip to content

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

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)#23
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 in Pipeline.upsert() when SourceCode.requirements is not set

Fixes aws#5518

Problem

When creating a TrainingStep with a SourceCode that does not specify requirements, calling pipeline.upsert() could trigger a TypeError: can only concatenate list (not "NoneType") to list during pipeline definition compilation.

The root cause is that SourceCode.requirements defaults to None, which gets passed as the dependencies parameter to code hash functions. While get_training_code_hash already has if dependencies: guards, get_processing_code_hash directly concatenates + dependencies without checking for None.

Fix

  • Added defensive dependencies = dependencies or [] defaulting at the start of get_processing_code_hash() to prevent TypeError when dependencies is None
  • Added clarifying comment in get_code_hash() documenting that source_code.requirements can be None and is handled downstream

Tests

  • Added test_get_processing_code_hash_with_none_dependencies - verifies no TypeError with code-only path
  • Added test_get_processing_code_hash_with_none_dependencies_and_source_dir - verifies no TypeError with source_dir path
  • Added test_get_training_code_hash_with_none_dependencies_and_source_dir - verifies no TypeError with source_dir
  • Added test_get_training_code_hash_with_none_dependencies_and_entry_point - verifies no TypeError with entry_point only

Related Issue

Fixes aws#5518

Changes Made

The bug is in the pipeline code path where SourceCode.requirements defaults to None, which gets passed as the dependencies parameter to get_training_code_hash(). While the current code in the repo has if dependencies: guards in get_training_code_hash, the get_processing_code_hash function does NOT have such guards and directly concatenates + dependencies. Additionally, the defensive approach should be applied at both call sites and within the hash functions themselves to prevent future regressions. The fix adds dependencies = dependencies or [] defaulting in get_processing_code_hash, and adds a None-safe fallback when reading source_code.requirements in the get_code_hash function's TrainingStep branch.

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 85%
  • 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.

Right before the line dependencies = dependencies or [], can you add a comment explaining why you made this decision?

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