Skip to content

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

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

Problem

When using a TrainingStep in a Pipeline where SourceCode.requirements is not set (defaults to None), calling pipeline.upsert() raises a TypeError: can only concatenate list (not 'NoneType') to list. This occurs during the code hash computation in get_code_hash()get_training_code_hash().

Root Cause

The get_code_hash() function reads source_code.requirements which can be None and passes it directly to get_training_code_hash() as the dependencies parameter. While get_training_code_hash() already has if dependencies: guards to prevent concatenation with None, the get_code_hash() function did not normalize falsy values (like empty strings) before passing them through.

Fix

  1. Defensive normalization in get_code_hash(): Changed requirements = source_code.requirements to requirements = source_code.requirements or None to handle both None and empty string edge cases.
  2. Verified existing guards: The get_training_code_hash() function already correctly checks if dependencies: before attempting list concatenation, which handles the None case.

Tests Added

  • test_get_training_code_hash_with_none_dependencies_source_dir - Verifies no TypeError when dependencies is None with source_dir
  • test_get_training_code_hash_with_none_dependencies_entry_point_only - Verifies no TypeError when dependencies is None with entry_point only
  • test_get_training_code_hash_with_default_dependencies - Verifies the default parameter value works correctly
  • test_get_code_hash_training_step_with_no_requirements - End-to-end test with mock TrainingStep and None requirements
  • test_get_code_hash_training_step_with_empty_string_requirements - End-to-end test with mock TrainingStep and empty string requirements

Related Issue

Fixes aws#5518

Changes Made

The bug occurs when SourceCode.requirements is not set (defaults to None) and a TrainingStep is used in a Pipeline. During pipeline.upsert()definition()get_code_hash(step), the code reads source_code.requirements (which is None) and passes it to get_training_code_hash() as the dependencies parameter. In the version the user is running (3.3.1), the function attempts [source_dir] + dependencies where dependencies is None, causing TypeError: can only concatenate list (not 'NoneType') to list. The current repo code already has if dependencies: guards in get_training_code_hash, but the fix needs to be verified as complete and properly tested. Additionally, the get_code_hash function in utilities.py should defensively handle None requirements before passing to get_training_code_hash to prevent this class of error.

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

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

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