You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5acb4af
Browse filesBrowse the repository at this point in the historyBrowse files
feat: Fail fast at boot when handlers and spec disagree (#88)
The default exception handler routed MissingOperationHandlerException
to a bare 500 at request time, so an OpenAPI operation declared in
the spec but missing from the handler map only surfaced when a client
hit it. ZAP picked this up against the example launcher and flagged
seven Server Error / Application Error Disclosure findings.
Validate handler/spec wiring at OpenApiServer.Builder.build() and
throw IllegalStateException with the offending operationIds when:
- a spec operationId has no registered handler, or
- a handler is registered for an operationId not in the spec.
Once the boot check is in place the dispatch-time null check, the
MissingOperationHandlerException class, and its unit test are
unreachable, so they are deleted.
The example ServerLauncher now registers stub handlers for every
operation in src/test/resources/openapi.json so the demo (and the
ZAP scan) covers the full surface. ServerBaseTest grows a
stubAllHandlers helper so the existing tests can keep registering
the subset they care about and pick up stubs for the rest.
Re-running ZAP against the updated launcher: no Server Error / no
Application Error Disclosure findings; only header hardening
warnings remain.
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Request flow when `OpenApiServer` boots (`src/main/java/com/retailsvc/http/OpenA
30
30
3. Three filters run in order on every request:
31
31
-`ExceptionFilter` — wraps the chain; delegates uncaught exceptions to the user-supplied `ExceptionHandler` (default in `Handlers`).
32
32
-`RequestPreparationFilter` — reads the raw request body, stashes it as an exchange attribute, runs OpenAPI parameter + body validation via `DefaultValidator`, and stores the resolved `operationId` on the exchange.
33
-
-`DispatchHandler` — looks up the `HttpHandler` registered for that `operationId` in the user-supplied map and invokes it. Missing handler → `MissingOperationHandlerException`.
33
+
-`DispatchHandler` — looks up the `HttpHandler` registered for that `operationId` in the user-supplied map and invokes it. Handler coverage is verified at boot, so the lookup never returns `null`.
0 commit comments