Skip to content

fix: default to empty list for docker build extra params metadata#8941

Merged
reedham-aws merged 2 commits into
developfrom
cdk-metadata-fix
Apr 28, 2026
Merged

fix: default to empty list for docker build extra params metadata#8941
reedham-aws merged 2 commits into
developfrom
cdk-metadata-fix

Conversation

@reedham-aws

@reedham-aws reedham-aws commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) does this change fix?

Why is this change necessary?

Integration tests are failing after: #8913.

https://github.com/aws/aws-sam-cli/actions/runs/25045806939/job/73360436775

How does it address the issue?

Changes the default from None to an empty list to avoid trying to convert None to TOML.

Error: Unable to convert an object of <class 'NoneType'> to a TOML item

What side effects does this change have?

An empty list would be carried around, but that's not too different from the build args where there's an empty dictionary.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@reedham-aws reedham-aws requested a review from a team as a code owner April 28, 2026 16:44
@reedham-aws

reedham-aws commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

https://github.com/aws/aws-sam-cli/actions/runs/25065781894

Edit: Integration tests that had been failing are now passing. Other failures are flaky.

@aws-sam-cli-bot aws-sam-cli-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review Results

Reviewed: 2138421..08f1a0e
Files: 1
Comments: 1

SAM_METADATA_DOCKER_CONTEXT_KEY: str(asset_path),
SAM_METADATA_DOCKER_BUILD_ARGS_KEY: metadata.get(ASSET_DOCKERFILE_BUILD_ARGS_KEY, {}),
SAM_METADATA_DOCKER_BUILD_EXTRA_PARAMS_KEY: metadata.get(ASSET_DOCKER_BUILD_EXTRA_PARAMS_KEY, None),
SAM_METADATA_DOCKER_BUILD_EXTRA_PARAMS_KEY: metadata.get(ASSET_DOCKER_BUILD_EXTRA_PARAMS_KEY, []),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[TESTING] Consider adding a unit test that verifies the default value of DockerBuildExtraParams when aws:asset:docker-build-extra-params is absent from the metadata. The existing test test_replace_all_resources_that_contain_image_metadata_dockerfile_extensions exercises this path (it omits the key from metadata) but does not assert on the resulting DockerBuildExtraParams value.

Since this PR specifically fixes a TOML serialization failure caused by None being set as the default, a targeted assertion would prevent regressions:

# In test_replace_all_resources_that_contain_image_metadata_dockerfile_extensions,
# after the existing assertions:
self.assertEqual(
   [], template_data["Resources"]["Function1"]["Metadata"]["DockerBuildExtraParams"]
)

This ensures the default stays as an empty list (TOML-serializable) rather than accidentally reverting to None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not concerned since this is caught in the integration tests. There are unit tests that test other aspects of this.

Comment thread samcli/lib/samlib/resource_metadata_normalizer.py
@reedham-aws reedham-aws enabled auto-merge April 28, 2026 17:07
@reedham-aws reedham-aws added this pull request to the merge queue Apr 28, 2026
Merged via the queue into develop with commit d6012ac Apr 28, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants