{"record":{"id":"a1052ab0d7e29bf6","repo":"testcontainers/testcontainers-java","slug":"you-cannot-specify-a-value-smaller-than-1-ms","errorCode":null,"errorMessage":"you cannot specify a value smaller than 1 ms","messagePattern":"you cannot specify a value smaller than 1 ms","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java","lineNumber":192,"sourceCode":"    /**\n     * Add multiple custom HTTP Headers to the call.\n     * @param headers Headers map of name/value\n     * @return this\n     */\n    public HttpWaitStrategy withHeaders(Map<String, String> headers) {\n        this.headers.putAll(headers);\n        return this;\n    }\n\n    /**\n     * Set the HTTP connections read timeout.\n     *\n     * @param timeout the timeout (minimum 1 millisecond)\n     * @return this\n     */\n    public HttpWaitStrategy withReadTimeout(Duration timeout) {\n        if (timeout.toMillis() < 1) {\n            throw new IllegalArgumentException(\"you cannot specify a value smaller than 1 ms\");\n        }\n        this.readTimeout = timeout;\n        return this;\n    }\n\n    /**\n     * Waits for the response to pass the given predicate\n     * @param responsePredicate The predicate to test the response against\n     * @return this\n     */\n    public HttpWaitStrategy forResponsePredicate(Predicate<String> responsePredicate) {\n        this.responsePredicate = responsePredicate;\n        return this;\n    }\n\n    @Override\n    protected void waitUntilReady() {\n        final String containerName = waitStrategyTarget.getContainerInfo().getName();","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java#L174-L210","documentation":"HttpWaitStrategy.withReadTimeout(Duration) validates that the per-request HTTP read timeout is at least 1 millisecond. Passing a zero or negative Duration (or one that truncates to <1 ms, like Duration.ofNanos(1)) throws IllegalArgumentException immediately at configuration time.","triggerScenarios":"Calling `new HttpWaitStrategy().withReadTimeout(Duration.ZERO)`, `withReadTimeout(Duration.ofMillis(0))`, or any negative/sub-millisecond duration.","commonSituations":"Configuring timeouts from computed values or external config where a 0 default slips through; typos like ofMillis(-1); unit confusion (nanoseconds vs milliseconds).","solutions":["Pass a duration of at least 1 millisecond, e.g. Duration.ofSeconds(2).","Clamp configured values: `Duration.ofMillis(Math.max(1, configured.toMillis()))`.","Check where the Duration is sourced (config file/env) for a zero or negative default."],"exampleFix":"// before\nnew HttpWaitStrategy().withReadTimeout(Duration.ofMillis(0));\n// after\nnew HttpWaitStrategy().withReadTimeout(Duration.ofSeconds(2));","handlingStrategy":"validation","validationCode":"void safeWithReadTimeout(HttpWaitStrategy s, Duration d) {\n  if (d == null || d.isNegative() || d.toMillis() < 1) throw new IllegalArgumentException(\"read timeout must be >= 1ms\");\n  s.withReadTimeout(d);\n}","typeGuard":"boolean isValidReadTimeout(Duration d) { return d != null && !d.isNegative() && d.toMillis() >= 1; }","tryCatchPattern":"try { strategy.withReadTimeout(configured); } catch (IllegalArgumentException e) { strategy.withReadTimeout(Duration.ofSeconds(2)); }","preventionTips":["Clamp externally-configured timeouts to a sane minimum before applying.","Avoid computing durations in sub-millisecond units.","Default to seconds-scale read timeouts (e.g. Duration.ofSeconds(2))."],"tags":["http","wait-strategy","timeout","illegal-argument"],"backgroundTag":"value-out-of-range","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}