mcl-rag#27: every HTTP handler returns {ok, Req, State} from init/2 #29

Manually merged
terra merged 2 commits from saturnus/27-handlers-return-ok into main 2026-12-01 15:34:11 +00:00
Member

Purpose (fix): every HTTP request ends cleanly. The request process no longer crashes after its reply, and the connection closes when the request asks it to.

Refs #27

  • 15 of the 17 handlers returned the reply Req alone from init/2. Each now returns {ok, Req, State}: the same three-line change everywhere, with _State renamed to State in 4. search_chunks_semantic and seed_corpus already did this.

  • New suite mcl_rag_http_handlers_end_SUITE, one case per handler (17). Each case sends its route two requests with connection: close:

    • one the handler answers without touching the store (a body that is not JSON, an unknown id, or a missing parameter);
    • one with a method the route does not take.

    It asserts the handler's own status, that the server closes the socket, and that nothing is logged at error level.

  • Red first: the suite is committed alone (fec5619). On 0397a80 it is red for exactly the 15 handlers, on the socket that never closes; the 2 handlers that already returned {ok, Req, State} are green.

  • Local runs: the new suite passes 17 of 17, rebar3 ct passes 97, and eunit, dialyzer and lint are green. The CHANGELOG entry is under Unreleased (0.11.2, with #26).

Purpose (fix): every HTTP request ends cleanly. The request process no longer crashes after its reply, and the connection closes when the request asks it to. Refs #27 - 15 of the 17 handlers returned the reply `Req` alone from `init/2`. Each now returns `{ok, Req, State}`: the same three-line change everywhere, with `_State` renamed to `State` in 4. search_chunks_semantic and seed_corpus already did this. - New suite `mcl_rag_http_handlers_end_SUITE`, one case per handler (17). Each case sends its route two requests with `connection: close`: - one the handler answers without touching the store (a body that is not JSON, an unknown id, or a missing parameter); - one with a method the route does not take. It asserts the handler's own status, that the server closes the socket, and that nothing is logged at error level. - Red first: the suite is committed alone (fec5619). On 0397a80 it is red for exactly the 15 handlers, on the socket that never closes; the 2 handlers that already returned `{ok, Req, State}` are green. - Local runs: the new suite passes 17 of 17, `rebar3 ct` passes 97, and eunit, dialyzer and lint are green. The CHANGELOG entry is under Unreleased (0.11.2, with #26).
Red on 0397a80 for the 15 handlers whose init/2 returns the reply Req alone.
mcl-rag#27: every HTTP handler's init/2 returns {ok, Req, State}
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 6m33s
lint-and-test / The tested lock arrives whole (pull_request) Successful in 2s
build-and-push / guard-1 (push) Successful in 4s
c4 model / c4-model-1 (push) Successful in 4s
c4 model / c4-model (push) Successful in 0s
build-and-push / check (push) Successful in 7m7s
build-and-push / The tested lock arrives whole (push) Has been skipped
build-and-push / test (push) Successful in 0s
build-and-push / Release (forge, v* tag) (push) Has been skipped
build-and-push / build-and-push (push) Successful in 3s
lint-and-test / check (push) Successful in 7m1s
lint-and-test / The tested lock arrives whole (push) Has been skipped
build-and-push / File the tested resolve for the signer (push) Successful in 3s
build-and-push / attest (push) Successful in 0s
build-and-push / guard (push) Successful in 0s
9b83f9eb9c
15 handlers returned the reply Req alone: the reply went out, then cowboy_handler failed with try_clause, an error
report was logged per request, and the connection stayed open despite connection: close.
terra manually merged commit 9b83f9eb9c into main 2026-12-01 15:34:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-rag!29
No description provided.