Describe the bug
ECSClient.get_service_details(), used by aws ecs deploy, has a broken conditional for defaulting the --cluster value:
def get_service_details(self):
cluster = self._args.cluster
if cluster is None or '':
cluster = 'default'
Due to Python operator precedence, this parses as if (cluster is None) or (''):. The empty string literal '' is always falsy, so it contributes nothing to the condition — the or '' is dead code. The check is silently equivalent to just if cluster is None:.
The command's own help text for --cluster says:
If you do not specify a cluster, the "default" cluster is assumed.
That's true when --cluster is omitted entirely (argparse leaves it as None). But if a caller passes --cluster "" — for example a CI/CD pipeline doing aws ecs deploy --cluster "$CLUSTER_NAME" ... where $CLUSTER_NAME is unset or empty — cluster is an empty string, not None, so the fallback to "default" is skipped and the empty string is sent straight through to DescribeServices.
Regression Issue
Expected Behavior
--cluster "" should be treated the same as omitting --cluster, and fall back to the "default" cluster, matching the documented behavior.
Current Behavior
describe_services is called with cluster='' instead of cluster='default', which does not match the documented "default cluster is assumed" fallback and will fail cluster/service resolution against the ECS API instead of deploying to the default cluster.
Demonstrated directly against ECSClient.get_service_details():
>>> client._args.cluster = ''
>>> client.get_service_details()
# describe_services is invoked with cluster='' instead of cluster='default'
Reproduction Steps
$ CLUSTER_NAME=
$ aws ecs deploy --service my-service --cluster "$CLUSTER_NAME" \
--task-definition file://task-def.json \
--codedeploy-appspec file://appspec.yaml
Because $CLUSTER_NAME is empty, this passes --cluster "", and the command does not fall back to the default cluster the way omitting --cluster entirely would.
Possible Solution
Replace the broken condition with if not cluster:, which correctly treats both None and '' as "not specified" and falls back to 'default' in both cases. I have a PR ready with the fix and regression tests (there was previously no test coverage at all for the cluster-defaulting behavior in get_service_details).
CLI version used
aws-cli/2.36.23 (reproduced on v2 at 4c331fc)
Environment details (OS name and version, etc.)
macOS 15 (Darwin 25.2.0), Python 3.12 — not OS-specific, this is a pure logic bug.
Describe the bug
ECSClient.get_service_details(), used byaws ecs deploy, has a broken conditional for defaulting the--clustervalue:Due to Python operator precedence, this parses as
if (cluster is None) or (''):. The empty string literal''is always falsy, so it contributes nothing to the condition — theor ''is dead code. The check is silently equivalent to justif cluster is None:.The command's own help text for
--clustersays:That's true when
--clusteris omitted entirely (argparseleaves it asNone). But if a caller passes--cluster ""— for example a CI/CD pipeline doingaws ecs deploy --cluster "$CLUSTER_NAME" ...where$CLUSTER_NAMEis unset or empty —clusteris an empty string, notNone, so the fallback to"default"is skipped and the empty string is sent straight through toDescribeServices.Regression Issue
Expected Behavior
--cluster ""should be treated the same as omitting--cluster, and fall back to the"default"cluster, matching the documented behavior.Current Behavior
describe_servicesis called withcluster=''instead ofcluster='default', which does not match the documented "default cluster is assumed" fallback and will fail cluster/service resolution against the ECS API instead of deploying to the default cluster.Demonstrated directly against
ECSClient.get_service_details():Reproduction Steps
Because
$CLUSTER_NAMEis empty, this passes--cluster "", and the command does not fall back to thedefaultcluster the way omitting--clusterentirely would.Possible Solution
Replace the broken condition with
if not cluster:, which correctly treats bothNoneand''as "not specified" and falls back to'default'in both cases. I have a PR ready with the fix and regression tests (there was previously no test coverage at all for the cluster-defaulting behavior inget_service_details).CLI version used
aws-cli/2.36.23 (reproduced on
v2at 4c331fc)Environment details (OS name and version, etc.)
macOS 15 (Darwin 25.2.0), Python 3.12 — not OS-specific, this is a pure logic bug.