Skip to content

fix: Allow object form of CodeUri in SAM Globals.Function - #4741

Merged
kddejong merged 2 commits into
aws-cloudformation:mainfrom
moneytool:fix/sam-globals-codeuri-object
Oct 20, 2026
Merged

kddejong merged 2 commits into
aws-cloudformation:mainfrom
moneytool:fix/sam-globals-codeuri-object

Conversation

@moneytool

@moneytool moneytool commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available: #4739

Description of changes:

Globals.Function.CodeUri was typed as string in src/cfnlint/data/schemas/other/sam/globals.json, so E3724 rejected the Bucket/Key/Version object form that AWS::Serverless::Function.CodeUri and the SAM translator accept. This is a regression since 1.54.0, when globals.json was introduced in #4491.

  • Function.CodeUri in globals.json now accepts a string or an object with the same keys as the resource schema's CodeUri definition (Bucket, Key, StorageMode, Version), with additionalProperties: false so typos are still reported.
  • required (Bucket, Key) is intentionally omitted from the Globals schema. Globals are merged into each resource's CodeUri before validation (_sam_globals._merge), so Globals may supply only some keys and the resource the rest. The resource-level schema still enforces both Bucket and Key on the merged result (E3003).
  • Added E3724 test cases for the object form (including Version and intrinsics), the string form, an intrinsic CodeUri, and an unknown key.

I compared every typed property in globals.json against the corresponding AWS::Serverless::* resource schema; Function.CodeUri was the only one narrower than the resource property.

The reproduction template from the issue previously reported E3724 {'Bucket': 'my-bucket', 'Key': 'code.zip'} is not of type 'string' and now lints clean.

Fixes #4739

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

moneytool and others added 2 commits October 7, 2026 22:44
Globals.Function.CodeUri was typed as string in globals.json, so E3724
rejected the Bucket/Key/Version object form that
AWS::Serverless::Function.CodeUri and the SAM translator accept.

Accept a string or an object with the same keys as the resource
schema's CodeUri definition (Bucket, Key, StorageMode, Version).
Bucket/Key are not required at the Globals level because SAM merges
Globals dicts into the resource property; the merged resource property
is still validated against the resource schema.

Fixes aws-cloudformation#4739
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (1f0e140) to head (2bbbfd0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4741   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         439      439           
  Lines       15858    15858           
  Branches     3067     3067           
=======================================
  Hits        15021    15021           
  Misses        457      457           
  Partials      380      380           
Flag Coverage Δ
unittests 94.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 1bb5e59 into aws-cloudformation:main Oct 20, 2026
22 checks passed
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.

E3724 rejects object-form CodeUri in SAM Globals.Function since 1.54.0

2 participants