From 5d6390fd986b277257e3f2272e8375b2ae5ed4cb Mon Sep 17 00:00:00 2001 From: Efremenko Arhip Date: Wed, 22 Jul 2026 14:59:15 +0300 Subject: [PATCH] fix(coordinator): stop masking 501 as an internal error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unimplemented endpoints answered {"error":"internal error"} because the detail-hiding branch covered everything >= 500, and 501 falls in that range. That is actively misleading: it sent one debugging session looking for a database fault when the endpoint simply had no implementation yet. 501 now says "not implemented". It leaks nothing — the client already knows the status code — while genuine 5xx responses keep hiding their details behind a request id. --- coordinator/internal/transport/http/errors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coordinator/internal/transport/http/errors.go b/coordinator/internal/transport/http/errors.go index d052a90..933b574 100644 --- a/coordinator/internal/transport/http/errors.go +++ b/coordinator/internal/transport/http/errors.go @@ -44,6 +44,14 @@ func (s *Server) writeError(w http.ResponseWriter, r *http.Request, err error) { status = http.StatusNotImplemented } + // 501 says "this endpoint has no implementation yet" — that leaks nothing and + // is far more useful than a generic failure, which sent one debugging session + // hunting a database problem that did not exist. + if status == http.StatusNotImplemented { + writeJSON(w, status, errorResponse{Error: "not implemented", RequestID: reqID}) + return + } + if status >= 500 { // Never echo an internal error: it can carry table names, query // fragments, and values. The request ID is the bridge to the logs.