Skip to content

Commit c14697b

Browse files
committed
pandaproxy: register default_404_handler in server::start()
Wires the new handler so Seastar's routes table dispatches to it for any (method, path) combination that no registered route matches. Without this, Seastar's built-in routes::handle() short-circuits with its own JSON body that uses {"code": 404} instead of the {"error_code": 404} shape SR clients expect, breaking 404-fallback paths in external SR client serializers. The handler is owned by pandaproxy::server via unique_ptr because Seastar's add_default_handler does not take ownership (per seastar/include/seastar/http/routes.hh:136). Declared before _server so it is destroyed after, giving the strongest lifetime guarantee for the routes table's raw pointer to it. Both REST proxy and schema registry use pandaproxy::server, so this fixes the body shape for both subsystems with a single registration.
1 parent ee07e38 commit c14697b

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/v/pandaproxy/server.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "model/metadata.h"
1313
#include "net/dns.h"
1414
#include "net/tls_certificate_probe.h"
15+
#include "pandaproxy/default_404_handler.h"
1516
#include "pandaproxy/json/types.h"
1617
#include "pandaproxy/logger.h"
1718
#include "pandaproxy/probe.h"
@@ -258,6 +259,10 @@ ss::future<> server::start(
258259
_server._routes.register_exeption_handler(
259260
exception_replier{ss::sstring{name(_exceptional_mime_type)}, _log});
260261

262+
_default_handler = std::make_unique<default_404_handler>(
263+
ss::sstring{name(_exceptional_mime_type)});
264+
_server._routes.add_default_handler(_default_handler.get());
265+
261266
_probe = std::make_unique<server_probe>(_ctx, _public_metrics_group_name);
262267

263268
_ctx.advertised_listeners.reserve(endpoints.size());

src/v/pandaproxy/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class server {
136136
ss::future<> stop();
137137

138138
private:
139+
std::unique_ptr<ss::httpd::handler_base> _default_handler;
139140
ss::httpd::http_server _server;
140141
ss::sstring _public_metrics_group_name;
141142
ss::gate _pending_reqs;

0 commit comments

Comments
 (0)