{"record":{"id":"1a16185b2d591626","repo":"testcontainers/testcontainers-java","slug":"couchbase-pools-did-not-return-valid-json","errorCode":null,"errorMessage":"Couchbase /pools did not return valid JSON","messagePattern":"Couchbase /pools did not return valid JSON","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java","lineNumber":390,"sourceCode":"\n    /**\n     * Before we can start configuring the host, we need to wait until the cluster manager is listening.\n     */\n    private void waitUntilNodeIsOnline() {\n        new HttpWaitStrategy().forPort(MGMT_PORT).forPath(\"/pools\").forStatusCode(200).waitUntilReady(this);\n    }\n\n    /**\n     * Fetches edition (enterprise or community) of started container.\n     */\n    private void initializeIsEnterprise() {\n        @Cleanup\n        Response response = doHttpRequest(MGMT_PORT, \"/pools\", \"GET\", null, true);\n\n        try {\n            isEnterprise = MAPPER.readTree(response.body().string()).get(\"isEnterprise\").asBoolean();\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Couchbase /pools did not return valid JSON\");\n        }\n\n        if (!isEnterprise) {\n            if (enabledServices.contains(CouchbaseService.ANALYTICS)) {\n                throw new IllegalStateException(\"The Analytics Service is only supported with the Enterprise version\");\n            }\n            if (enabledServices.contains(CouchbaseService.EVENTING)) {\n                throw new IllegalStateException(\"The Eventing Service is only supported with the Enterprise version\");\n            }\n        }\n    }\n\n    /**\n     * Initializes the {@link #hasTlsPorts} flag.\n     * <p>\n     * Community Edition might support TLS one happy day, so use a \"supports TLS\" flag separate from\n     * the \"enterprise edition\" flag.\n     */","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java#L372-L408","documentation":"During container startup CouchbaseContainer calls initializeIsEnterprise(), which GETs /pools from the management API and parses isEnterprise via Jackson. If the response body cannot be read as JSON (IOException from MAPPER.readTree), the container throws IllegalStateException because it cannot determine the edition and cannot validate service support.","triggerScenarios":"The Couchbase node's management API returned a non-JSON body (HTML error page, empty/garbage body, proxy interception) on GET /pools while the container is initializing.","commonSituations":"Container not fully started yet (startup/probe race), a corporate proxy or firewall rewriting responses, wrong image tag that isn't actually a Couchbase server, or resource exhaustion making the server return an error page.","solutions":["Ensure you use an official couchbase image tag and the container's exposed MGMT_PORT is reachable.","Retry the test — transient startup races usually disappear with a later Testcontainers version or longer wait strategy.","Check docker logs of the couchbase container and any HTTP proxy env vars (http_proxy/HTTP_PROXY) that could intercept container traffic.","Inspect what /pools actually returns (curl the mapped port) to see the malformed body."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure container is started and no proxy intercepts container traffic\nassertThat(System.getenv(\"HTTP_PROXY\")).isNull();\nContainerExecResult r = container.execInContainer(\"curl\", \"-s\", \"localhost:8091/pools\");\n// response should start with '{' before the library parses it","typeGuard":null,"tryCatchPattern":"try {\n    container.start();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"did not return valid JSON\")) {\n        container.stop();\n        container.start(); // retry once; often a startup race\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep Testcontainers updated for robust wait strategies.","Unset HTTP(S)_PROXY for the test JVM so container-internal calls aren't proxied.","Verify the image is an official couchbase server image.","Inspect docker logs when startup fails."],"tags":["testcontainers","couchbase","json","startup"],"backgroundTag":"invalid-json-response","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"}