{"record":{"id":"1ab42fc4345e6395","repo":"hs-web/hsweb-framework","slug":"method-not-allowed","errorCode":"method_not_allowed","errorMessage":"error.method_not_allowed","messagePattern":"error\\.method_not_allowed","errorType":"http","errorClass":"MethodNotAllowedException","httpStatus":406,"severity":"warning","filePath":"hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/CommonErrorControllerAdvice.java","lineNumber":259,"sourceCode":"                .result(e.getSupportedMediaTypes()));\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.NOT_ACCEPTABLE)\n    public Mono<ResponseMessage<Object>> handleException(NotAcceptableStatusException e) {\n        log.warn(e.getLocalizedMessage(), e);\n\n        return LocaleUtils\n            .resolveMessageReactive(\"error.not_acceptable_media_type\")\n            .map(msg -> ResponseMessage\n                .error(406, \"not_acceptable_media_type\", msg)\n                .result(e.getSupportedMediaTypes()));\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.NOT_ACCEPTABLE)\n    public Mono<ResponseMessage<Object>> handleException(MethodNotAllowedException e) {\n        log.warn(e.getLocalizedMessage(), e);\n\n        return LocaleUtils\n            .resolveMessageReactive(\"error.method_not_allowed\")\n            .map(msg -> ResponseMessage\n                .error(406, \"method_not_allowed\", msg)\n                .result(e.getSupportedMethods()));\n    }\n\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.BAD_REQUEST)\n    public Mono<ResponseMessage<List<ValidationException.Detail>>> handleException(ServerWebInputException e) {\n        Throwable exception = e;\n        do {\n            exception = exception.getCause();\n            if (exception instanceof ValidationException) {\n                return handleException(((ValidationException) exception));\n            }","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/hs-web/hsweb-framework/blob/b2cfc85a57c70bf5b5cf6e7edae2d37102652ec8/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/CommonErrorControllerAdvice.java#L241-L277","documentation":"WebFlux's MethodNotAllowedException is mapped (note: with @ResponseStatus(NOT_ACCEPTABLE) on the advice, while the ResponseMessage code is method_not_allowed) to the localized 'error.method_not_allowed' message and the supported methods in the result. It means the HTTP verb used on the URL has no matching handler mapping.","triggerScenarios":"Sending PUT to a collection URL that only defines GET/POST, DELETE on an endpoint without a delete handler, or calling a renamed/removed REST route with the old verb.","commonSituations":"API version drift between client and server; typos in HTTP method constants; REST clients defaulting to GET when posting; framework upgrade where a controller method was removed.","solutions":["Use one of the methods listed in the error response result (getSupportedMethods) for that URL.","Check the controller's @RequestMapping/@GetMapping etc. for the path and verbs actually exposed.","Update the client/SDK to the current API version if the route changed.","Fix typos in method names (e.g. Post vs Get) in the calling code."],"exampleFix":"// before\nawait axios.delete('/api/users'); // no DELETE on collection\n// after\nawait axios.delete(`/api/users/${id}`);","handlingStrategy":"validation","validationCode":"const route = { '/api/users': ['GET','POST'], '/api/users/{id}': ['GET','PUT','DELETE'] };\nconst verbs = route[url] || [];\nif (!verbs.includes(method)) {\n  console.warn(`${method} not allowed on ${url}; allowed: ${verbs.join(',')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await client.request({ method, url });\n} catch (e) {\n  if (e.response && (e.response.status === 405 || e.response.status === 406) && e.response.data.code === 'method_not_allowed') {\n    throw new Error(`Use one of: ${e.response.data.result}`);\n  }\n  throw e;\n}","preventionTips":["Generate client SDKs from OpenAPI specs so verbs stay in sync.","Pin client versions to API versions.","Avoid hand-written method strings; use client library constants.","Smoke-test all CRUD verbs per resource in CI."],"tags":["http-405","routing","webflux","spring"],"backgroundTag":"method-not-allowed","analyzedSha":"b2cfc85a57c70bf5b5cf6e7edae2d37102652ec8","analyzedAt":"2026-09-13T09:05:02.172Z","contentChangedAt":"2026-09-13T09:05:02.172Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}