fix(ls-api): align mock with LocalStack API and add regression test#101
Draft
joe4dev wants to merge 1 commit into
Draft
fix(ls-api): align mock with LocalStack API and add regression test#101joe4dev wants to merge 1 commit into
joe4dev wants to merge 1 commit into
Conversation
…on tests
- Return 202 Accepted from all handlers to match executor_endpoint.py
- Add missing InvokedFunctionArn and TraceId fields to InvokeRequest
- Parse {"logs":"..."} JSON in invokeLogsHandler instead of raw bytes
- Read and log request body in invokeErrorHandler
- Downgrade log.Fatal to log.Error in statusHandler goroutine
- Add main_test.go with 7 regression tests covering all endpoints,
JSON field names, and the async invoke triggered on status/ready
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dfangl
reviewed
Jun 3, 2026
Member
dfangl
left a comment
There was a problem hiding this comment.
I'm not quite sure what the purpose of this PR is - where is this ls-api mock used? It definitely improves the mock, but I don't quite understand where the mock itself is used and how we use it to test regressions?
Member
Author
Sorry for the noise. You're spot on. Converted back to draft. The test is not even using the mock nor the other code 🤦 |
Member
It's using the handlers of the mock at least, but that is about it :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The LocalStack ↔ RIE API contract (the HTTP endpoints that LocalStack calls on the RIE and vice versa) is currently unversioned. This is especially risky for Kubernetes deployments, where LocalStack and the Lambda container images (which embed the RIE) can be at different versions with no coordination mechanism. A silent mismatch — e.g. a renamed JSON field or a changed status code — would cause invocations to fail with no clear error.
This PR adds a regression test suite that pins the exact contract so that future changes are caught at review time rather than in production.
Changes
cmd/ls-api/main.go— align mock withexecutor_endpoint.pyThe existing mock was drifting from the real LocalStack API in several ways, which would have caused the new tests to pass incorrectly if left unfixed:
202 Acceptedto matchexecutor_endpoint.py(previously all defaulted to200 OK)invokeErrorHandlernow reads and logs the request body (was a no-op)invokeLogsHandlernow decodes the{"logs":"..."}JSON structure instead of reading raw bytesInvokeRequestgains the missinginvoked-function-arnandtrace-idfields thatcustom_interop.goactually sendsLogResponsestruct extracted and documentedlog.Fatalin thestatusHandlergoroutine downgraded tolog.Error(would have calledos.Exiton any connection failure, including during tests)cmd/ls-api/main_test.go— new regression tests7 unit tests covering the full LS↔RIE API surface:
TestInvocationResponseReturns202POST /invocations/{id}/response→ 202TestInvocationErrorReturns202POST /invocations/{id}/error→ 202TestInvocationLogsReturns202POST /invocations/{id}/logswith{"logs":"..."}→ 202TestStatusReadyReturns202AndTriggersInvokePOST /status/{id}/ready→ 202 + async invoke dispatchedTestStatusErrorReturns202POST /status/{id}/error→ 202TestInvokeRequestJSONFieldNames/invokeTestLogResponseJSONFieldName"logs"key the RIE sends back to LocalStackTestInvokeRequestJSONFieldNamescarries an explicit warning comment that the LS↔RIE API is unversioned and that field-name changes are silent breaking changes requiring coordinated releases of both repos.