Skip to content

Commit 99822c6

Browse files
singledigitclaude
andcommitted
fix: raise ExportFailedError in _get_target_index for multi-container TaskDef
Mirror the build path: when len(ContainerDefinitions) > 1 and Metadata.ContainerName is unset, sam package now raises ExportFailedError instead of silently packaging the first container. Prevents the wrong-container overwrite in standalone sam package invocations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 854065b commit 99822c6

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

samcli/lib/package/packageable_resources.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,14 @@ def _get_target_index(self, container_defs):
719719
),
720720
)
721721
if len(container_defs) > 1:
722-
LOG.warning(
723-
"TaskDefinition has multiple containers but Metadata.ContainerName is not set; "
724-
"packaging the first container. Add 'ContainerName: <name>' to the resource Metadata "
725-
"to avoid ambiguity."
722+
raise exceptions.ExportFailedError(
723+
resource_id="",
724+
property_name=self.PROPERTY_NAME,
725+
property_value="",
726+
ex=ValueError(
727+
f"TaskDefinition has {len(container_defs)} containers but Metadata.ContainerName is not set. "
728+
f"Add 'ContainerName: <name>' to the resource Metadata to specify which container to package."
729+
),
726730
)
727731
return 0
728732

0 commit comments

Comments
 (0)