Skip to content

Commit a08c667

Browse files
joe4devclaude
andcommitted
fix(init): include requestId in init error response even when empty
Use *string for the RequestId field in ErrorResponse so that an empty string is serialized (not omitted by omitempty), while nil — used for fault events — stays omitted. Fixes test_lambda_runtime_error snapshot mismatch where requestId: "" was expected but absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b9394b1 commit a08c667

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cmd/localstack/custom_interop.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ type InvokeRequest struct {
9393
type ErrorResponse struct {
9494
ErrorMessage string `json:"errorMessage"`
9595
ErrorType string `json:"errorType,omitempty"`
96-
RequestId string `json:"requestId,omitempty"`
96+
// RequestId uses *string so that an empty string "" is serialized (not omitted),
97+
// while nil is omitted — init errors always set this field, fault events leave it nil.
98+
RequestId *string `json:"requestId,omitempty"`
9799
StackTrace []string `json:"stackTrace,omitempty"`
98100
}
99101

@@ -235,10 +237,11 @@ func (c *CustomInteropServer) SendInitErrorResponse(resp *interop.ErrorInvokeRes
235237
return c.delegate.SendInitErrorResponse(resp)
236238
}
237239

240+
requestId := c.delegate.GetCurrentInvokeID()
238241
adaptedResp := ErrorResponse{
239242
ErrorMessage: parsed.ErrorMessage,
240243
ErrorType: parsed.ErrorType,
241-
RequestId: c.delegate.GetCurrentInvokeID(),
244+
RequestId: &requestId,
242245
StackTrace: parsed.StackTrace,
243246
}
244247
body, err := json.Marshal(adaptedResp)

0 commit comments

Comments
 (0)