Skip to content

Commit 4d352ef

Browse files
joe4devclaude
andcommitted
docs(init): document the deliberate dual shape of init error payloads
Runtime-reported error payloads include a blank "requestId" (and possibly an empty "stackTrace") on AWS, while platform-synthesized payloads (Sandbox.Timedout, Runtime.ExitError) carry neither — both validated by localstack-pro's AWS snapshots. Spell this out on lsapi.ErrorResponse and adaptInitErrorPayload so the asymmetry between the two ReportInitFailure paths is not mistaken for a bug and unified. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fc4092e commit 4d352ef

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

cmd/localstack/custom_interop.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ func (c *CustomInteropServer) ReportInitFailure(errType fatalerror.ErrorType, me
287287
// adaptInitErrorPayload injects the requestId into the runtime's structured /init/error
288288
// payload, preserving all other fields exactly as the runtime emitted them — in particular an
289289
// empty but present "stackTrace": [] (e.g. Runtime.HandlerNotFound), which a typed struct with
290-
// omitempty would drop on re-marshal. AWS includes a (blank) requestId in init error payloads.
290+
// omitempty would drop on re-marshal.
291+
//
292+
// AWS includes a (blank) "requestId" in runtime-reported init error payloads but NOT in
293+
// platform-synthesized ones (e.g. Runtime.ExitError) — see the lsapi.ErrorResponse doc for the
294+
// AWS-snapshot evidence. The two ReportInitFailure paths intentionally differ in this regard.
291295
// Returns nil if the payload cannot be adapted (it is then forwarded unmodified).
292296
func adaptInitErrorPayload(payload []byte, requestID string) []byte {
293297
var fields map[string]any

internal/lsapi/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ type LogResponse struct {
1414
}
1515

1616
// ErrorResponse is sent to LocalStack when encountering an error.
17+
//
18+
// It is used for payloads the platform synthesizes itself (e.g. Sandbox.Timedout,
19+
// Runtime.ExitError). On AWS these carry no requestId/stackTrace fields — unlike
20+
// runtime-reported error payloads, which include a blank "requestId" and possibly an empty
21+
// "stackTrace" (validated against AWS in localstack-pro's test_lambda.py snapshots, e.g.
22+
// test_lambda_invoke_with_timeout and test_lambda_init_timeout_then_crash vs
23+
// test_lambda_handler_not_found). Runtime-reported payloads are therefore forwarded
24+
// verbatim (see adaptInitErrorPayload) rather than re-marshaled through this struct, and
25+
// the omitempty tags here are deliberate.
1726
type ErrorResponse struct {
1827
ErrorMessage string `json:"errorMessage"`
1928
ErrorType string `json:"errorType,omitempty"`

0 commit comments

Comments
 (0)