t8y2/dbx · error · IllegalArgumentException

Agent runtime thread limits must be positive

Error message

Agent runtime thread limits must be positive

What it means

The RuntimeLimits constructor validates its thread-pool bounds and throws IllegalArgumentException if either maximumRequestThreads or maximumCleanupThreads is <= 0. It is a fail-fast guard ensuring the server always configures positive thread limits for its executor pools.

Source

Thrown at agents/common/src/main/java/com/dbx/agent/MultiSessionJsonRpcServer.java:359

    private static JsonObject errorResponse(JsonElement id, Throwable error) {
        JsonObject response = new JsonObject();
        response.addProperty("jsonrpc", "2.0");
        response.add("id", id);
        response.add("error", AgentRpcError.toJson(error, "request", null));
        return response;
    }

    private static String stringOrNull(JsonObject params, String key) {
        return params.has(key) && !params.get(key).isJsonNull() ? params.get(key).getAsString() : null;
    }

    static final class RuntimeLimits {
        private final int maximumRequestThreads;
        private final int maximumCleanupThreads;

        RuntimeLimits(int maximumRequestThreads, int maximumCleanupThreads) {
            if (maximumRequestThreads <= 0 || maximumCleanupThreads <= 0) {
                throw new IllegalArgumentException("Agent runtime thread limits must be positive");
            }
            this.maximumRequestThreads = maximumRequestThreads;
            this.maximumCleanupThreads = maximumCleanupThreads;
        }

        private static RuntimeLimits defaults() {
            return new RuntimeLimits(MAX_REQUEST_THREADS, MAX_CLEANUP_THREADS);
        }
    }

    private static String requiredSessionId(JsonObject params) {
        if (!params.has("agentSessionId") || params.get("agentSessionId").getAsString().trim().isEmpty()) {
            throw new IllegalArgumentException("agentSessionId is required");
        }
        return params.get("agentSessionId").getAsString();
    }

    private void writeResponse(JsonObject response) {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Pass positive values for both limits (use RuntimeLimits defaults if unsure)
  2. Validate config values before constructing and fall back to defaults on invalid input
  3. Fix the configuration source so thread-count properties are positive integers
  4. Add a startup assertion/log when config-derived values are non-positive

Example fix

// before
int threads = Integer.parseInt(cfg.get("requestThreads")); // 0 on missing
new MultiSessionJsonRpcServer(agent, threads, threads);
// after
int threads = Math.max(1, Integer.parseInt(cfg.getOrDefault("requestThreads", "8")));
new MultiSessionJsonRpcServer(agent, threads, Math.max(1, cleanupThreads));
Defensive patterns

Strategy: validation

Validate before calling

int req = parsePositive(cfg, "requestThreads", 8);
int cleanup = parsePositive(cfg, "cleanupThreads", 2);
// parsePositive throws/defaults when value <= 0
new MultiSessionJsonRpcServer(agent, req, cleanup);

Type guard

boolean validLimits(int req, int cleanup) { return req > 0 && cleanup > 0; }

Try / catch

try {
    limits = new RuntimeLimits(reqThreads, cleanupThreads);
} catch (IllegalArgumentException e) {
    limits = RuntimeLimits.defaults(); // fall back to built-in positive defaults
}

Prevention

When it happens

Trigger: Constructing MultiSessionJsonRpcServer (or RuntimeLimits directly) with 0 or negative values, typically from misread config properties, integer-parse fallbacks, or constants defined as 0.

Common situations: Config file with 'threads=0' or a negative override; parsing empty strings to 0 and passing them through; unit tests probing validation; copy-paste errors in constant definitions.

Understand the failure class

Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/63479636cbbc258a. Report an issue: GitHub.