Repository navigation
Bring nats.micro in line with the service ADR - #1131
caspervonb wants to merge 2 commits into
Conversation
Running the legacy service API through the ADR-32 conformance suite turned up a set of places where it disagrees with the specification: - Metadata was kept by reference, so changing the dict after creating a service or endpoint changed what INFO reports. - reset() moved the start time and left the endpoint counters alone. - An error sent with respond_error was not counted in the stats. - INFO sent a null description when none was set. - Endpoints could subscribe to subjects under $SRV. - Queue groups holding whitespace, '.', '*' or '>' were accepted. - respond_error accepted an empty code or description. - stop() dropped requests that were still being handled. Refusing these queue groups, subjects and error values is a change in behavior for callers that relied on them.
|
Claude finished @caspervonb's task in 2m 24s —— View job Reviewing PR #1131
SummaryReviewed the ADR-32 conformance fixes (metadata copying, Found one real issue: in Also noted (non-blocking): Full summary posted as a PR comment. |
| self._record_error(repr(error)) | ||
|
|
||
| if isinstance(error, ServiceError): | ||
| await request.respond_error(error.code, error.description) |
There was a problem hiding this comment.
respond_error now raises ValueError for an empty code or description (request.py:78-82). If a handler raises a ServiceError with an empty code/description, this line will raise that ValueError from inside the except block, which is not caught here. It propagates out of _handle_request into the subscription's message loop, where it's only passed to error_cb (nats/src/nats/aio/subscription.py:315-319) — no response is ever sent to the caller, so the original RPC will time out instead of receiving an error response (a behavior regression vs. before this validation existed). Worth guarding against, e.g. falling back to a default code/description here instead of forwarding a possibly-invalid ServiceError.
Review summaryVerified the fixes against the current One correctness concern, left as an inline comment on Minor/non-blocking: |
respond_error now refuses an empty code or description, so a handler raising ServiceError with either left empty made the framework's own error response raise, and the caller timed out without a reply. Fall back to code 500 and the error's repr instead.
Running
nats.microthrough the ADR-32 conformance suite showed it disagreeing with the service ADR in several places: metadata kept by reference,reset()moving the start time instead of clearing counters,respond_errornot counted in stats, a null INFO description, endpoints allowed under$SRV, invalid queue groups accepted, empty error codes and descriptions accepted, andstop()dropping requests still being handled.Refusing queue groups that hold whitespace,
.,*or>, endpoint subjects under$SRV, and empty error codes or descriptions is a behavior change for callers that relied on them.