Skip to content

fix(intrinsics): only resolve the selected Fn::If branch#9134

Open
EPNOS wants to merge 3 commits into
aws:developfrom
EPNOS:fix/4510-lazy-fn-if-resolution
Open

fix(intrinsics): only resolve the selected Fn::If branch#9134
EPNOS wants to merge 3 commits into
aws:developfrom
EPNOS:fix/4510-lazy-fn-if-resolution

Conversation

@EPNOS

@EPNOS EPNOS commented Jul 20, 2026

Copy link
Copy Markdown

Which issue(s) does this change fix?

Fixes #4510, Fixes #6205

Why is this change necessary?

Fn::If eagerly resolved both the true and false branches before checking
the condition. If the branch that the condition did NOT select contained a
value the local resolver can't handle (e.g. Fn::GetAtt to a FunctionUrl
attribute, or !Ref AWS::NoValue in a Layers list), resolution of the
entire Fn::If failed even though the condition picked the other,
perfectly resolvable branch. sam deploy/sam build were unaffected since
CloudFormation itself only evaluates the selected branch.

How does it address the issue?

  • handle_fn_if now evaluates the condition first and only recursively
    resolves the branch it selects, instead of resolving both branches
    unconditionally.
  • handle_fn_getatt now forwards its own ignore_errors argument to
    resolve_symbols, which it previously dropped. This matters once the
    Fn::If fix is in place: if the selected branch itself contains an
    unsupported Fn::GetAtt, ignore_errors=True should still let it
    degrade to a placeholder instead of raising.

What side effects does this change have?

None expected. Both branches were already required to independently
type-check before this change; only the eager resolution of the unselected
branch's value is removed.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Review the generative AI contribution guidelines
  • Add input/output type hints to new functions/methods
  • Write design document if needed
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

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

EPNOS added 3 commits July 19, 2026 19:01
Fn::If eagerly resolved both the true and false branches before
checking the condition, so an unresolvable value in the branch
NOT selected (e.g. Fn::GetAtt to FunctionUrl, which sam local
invoke can't resolve) caused the whole intrinsic to be left
unresolved even though the condition picked the other, resolvable
branch.

Fixes aws#4510, Fixes aws#6205
handle_fn_getatt called resolve_symbols without forwarding its own
ignore_errors argument, so resolve_symbols always defaulted to False.
Any Fn::GetAtt referencing an attribute the local resolver doesn't
support (e.g. FunctionUrl) raised even when the caller explicitly
asked to ignore errors, instead of falling back to a placeholder.
…le branch

Reproduces the aws#4510 scenario end-to-end via sam local invoke: an
environment variable that uses Fn::If where the selected branch is a
resolvable Ref and the other branch is Fn::GetAtt to a FunctionUrl
attribute, which the local resolver can't handle.
@EPNOS
EPNOS requested a review from a team as a code owner July 20, 2026 02:37
@github-actions github-actions Bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: sam local invoke fails when Globals.Function.Layers contains AWS::NoValue Bug: Unable to resolve env var when referencing FunctionUrl

1 participant