Skip to content

Commit 5bb7698

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 ca2d4f8 commit 5bb7698

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

cmd/localstack/custom_interop.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ func (c *CustomInteropServer) SendInitErrorResponse(resp *interop.ErrorInvokeRes
223223
return c.delegate.SendInitErrorResponse(resp)
224224
}
225225

226+
requestId := c.delegate.GetCurrentInvokeID()
226227
adaptedResp := lsapi.ErrorResponse{
227228
ErrorMessage: parsed.ErrorMessage,
228229
ErrorType: parsed.ErrorType,
229-
RequestId: c.delegate.GetCurrentInvokeID(),
230+
RequestId: &requestId,
230231
StackTrace: parsed.StackTrace,
231232
}
232233
body, err := json.Marshal(adaptedResp)

internal/lsapi/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ type LogResponse struct {
1717
type ErrorResponse struct {
1818
ErrorMessage string `json:"errorMessage"`
1919
ErrorType string `json:"errorType,omitempty"`
20-
RequestId string `json:"requestId,omitempty"`
20+
// RequestId uses *string so that an empty string "" is serialized (not omitted),
21+
// while nil is omitted — init errors always set this field, fault events leave it nil.
22+
RequestId *string `json:"requestId,omitempty"`
2123
StackTrace []string `json:"stackTrace,omitempty"`
2224
}

0 commit comments

Comments
 (0)