Skip to content

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

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)#24
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 dependencies is None in get_processing_code_hash

Fixes aws#5518

Problem

When dependencies is passed as None to get_processing_code_hash(), the function attempts to concatenate a list with None (e.g., [code, source_dir] + dependencies), which raises:

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

The same pattern was already fixed in get_training_code_hash() with if dependencies: guards, but get_processing_code_hash() was left unprotected.

Solution

Added a defensive dependencies = dependencies or [] at the start of get_processing_code_hash() to normalize None to an empty list before any list concatenation occurs.

Testing

Added two new test cases:

  • test_get_processing_code_hash_with_none_dependencies — verifies no TypeError when source_dir is provided with dependencies=None
  • test_get_processing_code_hash_code_only_with_none_dependencies — verifies no TypeError when only code is provided with dependencies=None

Existing tests for get_training_code_hash with dependencies=None continue to pass.

Related Issue

Fixes aws#5518

Changes Made

The bug occurs when SourceCode.requirements is not set (defaults to None), and the pipeline's get_code_hash() function passes this None value as dependencies to get_training_code_hash(). In the released v3.3.1, get_training_code_hash() directly concatenates [source_dir] + dependencies which fails with TypeError: can only concatenate list (not 'NoneType') to list. The fix in the current repo already guards this with if dependencies: checks in get_training_code_hash(). However, get_processing_code_hash() has the same fragile pattern — it directly concatenates + dependencies without a None guard, relying on the caller to always pass a list. This should also be hardened with a defensive default.

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)

@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:43
Copy link
Copy Markdown
Owner Author

@aviruthen aviruthen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Code Review

The fix addresses a real bug where dependencies=None causes a TypeError in get_processing_code_hash(), but the diff appears to have a critical issue — the if source_dir: guard was removed, which would break the function's control flow. The tests are well-structured and cover the relevant cases.

@@ -211,7 +211,9 @@ def get_processing_code_hash(code: str, source_dir: str, dependencies: List[str]
"""

# FrameworkProcessor
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.

Critical bug in the diff: It appears the if source_dir: line was removed (shown as - if source_dir: in the diff), but the indented block below it still expects that conditional guard. This would cause the code under the old if source_dir: block to execute unconditionally, meaning when source_dir=None, the function would attempt urlparse(None) instead of falling through to the code-only path.

The fix should be:

dependencies = dependencies or []

if source_dir:
    source_dir_url = urlparse(source_dir)

Please verify the diff is correct — the if source_dir: line must be preserved. If this is a diff rendering issue, please confirm the actual file still contains the conditional.

assert result is not None
assert len(result) == 64

def test_get_processing_code_hash_code_only_with_none_dependencies(self):
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.

Minor: This test uses tempfile.NamedTemporaryFile with manual os.unlink cleanup, while the test above uses tempfile.TemporaryDirectory which handles cleanup automatically. Consider using TemporaryDirectory here as well for consistency, or at minimum use a pytest.fixture / context manager pattern to ensure cleanup even if an assertion fails before finally. That said, the try/finally does handle it — this is a minor style suggestion.

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