{"record":{"id":"ce683ffb63a150a6","repo":"alibaba/Sentinel","slug":"invalid-http-status-code-httpstatus","errorCode":null,"errorMessage":"Invalid HTTP status code: ${httpStatus}","messagePattern":"Invalid HTTP status code: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webmvc_v6x/config/WebServletLocalConfig.java","lineNumber":81,"sourceCode":"            if (s <= 0) {\n                throw new IllegalArgumentException(\"Invalid status code: \" + s);\n            }\n            return s;\n        } catch (Exception e) {\n            RecordLog.warn(\"[WebServletConfig] Invalid block HTTP status (\" + value + \"), using default 429\");\n            setBlockPageHttpStatus(HTTP_STATUS_TOO_MANY_REQUESTS);\n        }\n        return HTTP_STATUS_TOO_MANY_REQUESTS;\n    }\n\n    /**\n     * Set the HTTP status of the default block page.\n     *\n     * @param httpStatus the HTTP status of the default block page\n     */\n    public static void setBlockPageHttpStatus(int httpStatus) {\n        if (httpStatus <= 0) {\n            throw new IllegalArgumentException(\"Invalid HTTP status code: \" + httpStatus);\n        }\n        SentinelConfig.setConfig(BLOCK_PAGE_HTTP_STATUS_CONF_KEY, String.valueOf(httpStatus));\n    }\n\n    private WebServletLocalConfig() {}\n}\n","sourceCodeStart":63,"sourceCodeEnd":88,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webmvc_v6x/config/WebServletLocalConfig.java#L63-L88","documentation":"WebServletLocalConfig.setBlockPageHttpStatus(int) (Spring Web MVC v6x adapter) validates the HTTP status used for the default block page and rejects values <= 0 with IllegalArgumentException. Sentinel stores the status as a config string under the block-page-status key; zero or negative values are not valid HTTP status codes, so this is a fail-fast configuration check.","triggerScenarios":"Calling WebServletLocalConfig.setBlockPageHttpStatus(0) or any negative value; reading a status property from config/env and passing it unvalidated.","commonSituations":"Property placeholders that resolve to 0 when a variable is missing (e.g. ${block.status:0}); parsing errors defaulting to 0; copy-paste of a status code list where 0 slips in.","solutions":["Pass a valid HTTP status, typically 429 (Too Many Requests) or 503 (Service Unavailable)","Validate externally sourced values before calling: if (code > 0) setBlockPageHttpStatus(code)","Fix the property placeholder default, e.g. ${block.page.status:429}"],"exampleFix":"// before\nint status = env.getProperty(\"block.status\", int.class, 0);\nWebServletLocalConfig.setBlockPageHttpStatus(status);\n\n// after\nint status = env.getProperty(\"block.status\", int.class, 429);\nWebServletLocalConfig.setBlockPageHttpStatus(status);","handlingStrategy":"validation","validationCode":"int status = parsedStatus > 0 ? parsedStatus : 429;\nWebServletLocalConfig.setBlockPageHttpStatus(status);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give property placeholders safe defaults like ${block.status:429}","Treat a parsed 0 as 'missing config' and substitute a valid status before calling the setter"],"tags":["spring-webmvc","servlet","configuration","http-status","illegal-argument"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}