{"record":{"id":"6147a2e7094d9cad","repo":"apache/skywalking","slug":"invalid-limits-6147a2","errorCode":"invalid_limits","errorMessage":"recordCap must be > 0, got {recordCap}","messagePattern":"recordCap must be > 0, got (.+?)","errorType":"http","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"warning","filePath":"oap-server/server-admin/dsl-debugging/src/main/java/org/apache/skywalking/oap/server/admin/dsl/debugging/session/SessionLimits.java","lineNumber":68,"sourceCode":"\n    /**\n     * Hard upper bound on the per-session retention window (1 hour). Sessions\n     * are operator-driven and short-lived by design; a runaway retention would\n     * keep payload JSON pinned in heap long after the operator has left.\n     */\n    public static final long MAX_RETENTION_MILLIS = 60L * 60 * 1000;\n\n    public static final SessionLimits DEFAULT =\n        new SessionLimits(MAX_RECORD_CAP, 5L * 60 * 1000, Granularity.DEFAULT);\n\n    private final int recordCap;\n    private final long retentionMillis;\n    private final Granularity granularity;\n\n    public SessionLimits(final int recordCap, final long retentionMillis,\n                         final Granularity granularity) {\n        if (recordCap <= 0) {\n            throw new IllegalArgumentException(\n                \"recordCap must be > 0, got \" + recordCap);\n        }\n        if (recordCap > MAX_RECORD_CAP) {\n            throw new IllegalArgumentException(\n                \"recordCap \" + recordCap + \" exceeds hard cap \" + MAX_RECORD_CAP);\n        }\n        if (retentionMillis <= 0) {\n            throw new IllegalArgumentException(\n                \"retentionMillis must be > 0, got \" + retentionMillis);\n        }\n        if (retentionMillis > MAX_RETENTION_MILLIS) {\n            throw new IllegalArgumentException(\n                \"retentionMillis \" + retentionMillis + \" exceeds hard cap \" + MAX_RETENTION_MILLIS);\n        }\n        this.recordCap = recordCap;\n        this.retentionMillis = retentionMillis;\n        this.granularity = granularity == null ? Granularity.DEFAULT : granularity;\n    }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-admin/dsl-debugging/src/main/java/org/apache/skywalking/oap/server/admin/dsl/debugging/session/SessionLimits.java#L50-L86","documentation":"SessionLimits' constructor enforces a lower bound on recordCap: it must be strictly positive. recordCap caps how many raw records (spans/logs) a DSL debugging session retains; zero or negative values are meaningless for a capture buffer, so the constructor rejects them immediately with an invalid_limits IllegalArgumentException.","triggerScenarios":"POST /dsl-debugging/session with a JSON body containing \"recordCap\": 0 or a negative number; or constructing SessionLimits programmatically with 0. Any non-positive value hits this branch before the upper-cap check.","commonSituations":"Client scripts defaulting numeric fields to 0 and sending them unconditionally; misreading '0' as 'unlimited'; copy-pasting a template that zero-fills optional fields.","solutions":["Omit recordCap from the request to use the default, or send a positive value (1..MAX_RECORD_CAP)","Fix client code that zero-fills optional numeric fields to omit them instead","Treat 'unlimited' as 'omit the field', never as 0"],"exampleFix":"// before\n{\"recordCap\": 0, \"retentionMillis\": 300000}\n// after\n{\"retentionMillis\": 300000}","handlingStrategy":"validation","validationCode":"// Client-side: only send positive recordCap, omit otherwise\nInteger cap = requestedCap != null && requestedCap > 0 ? requestedCap : null;","typeGuard":"function isValidRecordCap(v: unknown): boolean {\n  return v === undefined || (Number.isInteger(v) && v > 0 && v <= MAX_RECORD_CAP);\n}","tryCatchPattern":"Treat the invalid_limits HTTP error as a client bug: fix the payload generator; catching/retrying adds nothing since the server will reject the same value again.","preventionTips":["Never zero-fill optional numeric fields in request builders — omit them","Centralize session-limit construction in one client helper that clamps/validates before sending"],"tags":["dsl-debugging","validation","session-limits"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}