alibaba/Sentinel · error · IllegalArgumentException

Invalid HTTP status code: ${httpStatus}

Error message

Invalid HTTP status code: ${httpStatus}

What it means

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.

Source

Thrown at sentinel-adapter/sentinel-spring-webmvc-v6x-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webmvc_v6x/config/WebServletLocalConfig.java:81

            if (s <= 0) {
                throw new IllegalArgumentException("Invalid status code: " + s);
            }
            return s;
        } catch (Exception e) {
            RecordLog.warn("[WebServletConfig] Invalid block HTTP status (" + value + "), using default 429");
            setBlockPageHttpStatus(HTTP_STATUS_TOO_MANY_REQUESTS);
        }
        return HTTP_STATUS_TOO_MANY_REQUESTS;
    }

    /**
     * Set the HTTP status of the default block page.
     *
     * @param httpStatus the HTTP status of the default block page
     */
    public static void setBlockPageHttpStatus(int httpStatus) {
        if (httpStatus <= 0) {
            throw new IllegalArgumentException("Invalid HTTP status code: " + httpStatus);
        }
        SentinelConfig.setConfig(BLOCK_PAGE_HTTP_STATUS_CONF_KEY, String.valueOf(httpStatus));
    }

    private WebServletLocalConfig() {}
}

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Pass a valid HTTP status, typically 429 (Too Many Requests) or 503 (Service Unavailable)
  2. Validate externally sourced values before calling: if (code > 0) setBlockPageHttpStatus(code)
  3. Fix the property placeholder default, e.g. ${block.page.status:429}

Example fix

// before
int status = env.getProperty("block.status", int.class, 0);
WebServletLocalConfig.setBlockPageHttpStatus(status);

// after
int status = env.getProperty("block.status", int.class, 429);
WebServletLocalConfig.setBlockPageHttpStatus(status);
Defensive patterns

Strategy: validation

Validate before calling

int status = parsedStatus > 0 ? parsedStatus : 429;
WebServletLocalConfig.setBlockPageHttpStatus(status);

Prevention

When it happens

Trigger: Calling WebServletLocalConfig.setBlockPageHttpStatus(0) or any negative value; reading a status property from config/env and passing it unvalidated.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/ce683ffb63a150a6. Report an issue: GitHub.