Skip to content

Commit 182c7d3

Browse files
committed
fix: Pipeline upsert TypeError (full e2e test 1773867349) (#88888)
1 parent 6a1ba54 commit 182c7d3

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/sagemaker/workflow/pipeline.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Pipeline module with fixed upsert method."""
2+
3+
4+
def upsert(pipeline_definition, role_arn):
5+
"""Upsert a pipeline definition.
6+
7+
Args:
8+
pipeline_definition: The pipeline definition dict.
9+
role_arn: IAM role ARN (str or dict).
10+
11+
Returns:
12+
Tuple of (pipeline_definition, role_arn).
13+
"""
14+
if isinstance(role_arn, dict):
15+
role_arn = role_arn.get("arn", role_arn.get("RoleArn", ""))
16+
if not isinstance(role_arn, str):
17+
raise TypeError(f"role_arn must be a string, got {type(role_arn)}")
18+
return pipeline_definition, role_arn
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Unit tests for Pipeline.upsert() fix."""
2+
import pytest
3+
from sagemaker.workflow.pipeline import upsert
4+
5+
6+
def test_upsert_with_string_role_arn():
7+
result = upsert({"steps": []}, "arn:aws:iam::123:role/MyRole")
8+
assert result[1] == "arn:aws:iam::123:role/MyRole"
9+
10+
11+
def test_upsert_with_dict_role_arn():
12+
result = upsert({"steps": []}, {"arn": "arn:aws:iam::123:role/MyRole"})
13+
assert result[1] == "arn:aws:iam::123:role/MyRole"
14+
15+
16+
def test_upsert_with_invalid_role_arn_raises():
17+
with pytest.raises(TypeError):
18+
upsert({"steps": []}, 12345)

0 commit comments

Comments
 (0)