Skip to content

Commit f2d5237

Browse files
committed
chore: log swallowed exceptions in _partial_resolve at debug level
_partial_resolve and _partial_resolve_find_in_map intentionally substitute AWS::NoValue / partial args for false-condition resources when the resolver raises. The swallow matches the Kotlin reference implementation and is not changing. The problem is debuggability: if a resolver bug or unexpected type slips through, the swallow hides it and the user sees a template with AWS::NoValue substitutions that look intentional. Adding LOG.debug with exc_info=True surfaces the traceback under --debug and in telemetry without changing any runtime behavior. Three swallow sites covered: - Ref substitution fallback - Generic Fn::* substitution fallback - Fn::FindInMap secondary fallback inside _partial_resolve_find_in_map The Re-raised InvalidTemplateException branch in _partial_resolve_find_in_map is unchanged — that path must error.
1 parent fd0bedd commit f2d5237

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • samcli/lib/cfn_language_extensions

samcli/lib/cfn_language_extensions/api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,23 @@ def _partial_resolve(self, value: Any) -> Any:
231231
try:
232232
return self._resolver.resolve_value(value)
233233
except (InvalidTemplateException, UnresolvableReferenceError, KeyError, ValueError, TypeError):
234+
LOG.debug(
235+
"Partial-resolve: substituting AWS::NoValue for unresolvable Ref %r",
236+
inner_value,
237+
exc_info=True,
238+
)
234239
return {"Ref": "AWS::NoValue"}
235240

236241
elif key.startswith("Fn::") or key == "Condition":
237242
# Try to resolve it
238243
try:
239244
return self._resolver.resolve_value(value)
240245
except (InvalidTemplateException, UnresolvableReferenceError, KeyError, ValueError, TypeError):
246+
LOG.debug(
247+
"Partial-resolve: could not resolve %s; falling back to partial args",
248+
key,
249+
exc_info=True,
250+
)
241251
# Can't resolve - replace unresolvable parts with AWS::NoValue
242252
if key == "Fn::FindInMap":
243253
# FindInMap - try to partially resolve arguments
@@ -310,6 +320,12 @@ def _partial_resolve_find_in_map(self, value: Dict[str, Any]) -> Any:
310320
raise
311321
except Exception:
312322
# Other errors - return with partially resolved args
323+
LOG.debug(
324+
"Partial-resolve Fn::FindInMap: unexpected error resolving %r; "
325+
"returning partially-resolved args",
326+
resolved_args,
327+
exc_info=True,
328+
)
313329
return {"Fn::FindInMap": resolved_args}
314330

315331
# Some args are not strings - return with partially resolved args

0 commit comments

Comments
 (0)