{"record":{"id":"9a0d3f302c30ae83","repo":"testcontainers/testcontainers-java","slug":"couchbase-pools-default-nodeservices-did-not-return-valid","errorCode":null,"errorMessage":"Couchbase /pools/default/nodeServices did not return valid JSON","messagePattern":"Couchbase /pools/default/nodeServices 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":424,"sourceCode":"     * Community Edition might support TLS one happy day, so use a \"supports TLS\" flag separate from\n     * the \"enterprise edition\" flag.\n     */\n    private void initializeHasTlsPorts() {\n        @Cleanup\n        Response response = doHttpRequest(MGMT_PORT, \"/pools/default/nodeServices\", \"GET\", null, true);\n\n        try {\n            String clusterTopology = response.body().string();\n            hasTlsPorts =\n                !MAPPER\n                    .readTree(clusterTopology)\n                    .path(\"nodesExt\")\n                    .path(0)\n                    .path(\"services\")\n                    .path(\"mgmtSSL\")\n                    .isMissingNode();\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Couchbase /pools/default/nodeServices did not return valid JSON\");\n        }\n    }\n\n    /**\n     * Rebinds/renames the internal hostname.\n     * <p>\n     * To make sure the internal hostname is different from the external (alternate) address and the SDK can pick it\n     * up automatically, we bind the internal hostname to the internal IP address.\n     */\n    private void renameNode() {\n        logger().debug(\"Renaming Couchbase Node from localhost to {}\", getHost());\n\n        @Cleanup\n        Response response = doHttpRequest(\n            MGMT_PORT,\n            \"/node/controller/rename\",\n            \"POST\",\n            new FormBody.Builder().add(\"hostname\", getInternalIpAddress()).build(),","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java#L406-L442","documentation":"initializeHasTlsPorts() GETs /pools/default/nodeServices from the management API to discover which services expose TLS ports (e.g. mgmtSSL under nodesExt[0].services). If the body cannot be parsed as JSON (IOException), the container throws IllegalStateException since TLS port detection is required for further configuration.","triggerScenarios":"The management API returned a non-JSON body for /pools/default/nodeServices during container initialization — e.g. an HTML error page, empty body, or proxy-injected content.","commonSituations":"Startup race where the node isn't ready; proxy/firewall interference with container HTTP traffic; wrong or corrupted image; server erroring under memory pressure.","solutions":["Retry the test run; upgrade Testcontainers for more robust wait strategies.","Check container logs and curl the mapped management port endpoint /pools/default/nodeServices to inspect the raw body.","Disable/inspect HTTP proxy environment variables that could intercept the request.","Ensure the image is an official, complete couchbase server image."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"ContainerExecResult r = container.execInContainer(\"curl\", \"-s\", \"localhost:8091/pools/default/nodeServices\");\n// body should be valid JSON before the library parses it\nif (!r.getStdout().trim().startsWith(\"{\")) throw new IllegalStateException(\"nodeServices not ready\");","typeGuard":null,"tryCatchPattern":"try {\n    container.start();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"nodeServices did not return valid JSON\")) {\n        container.stop();\n        container.start(); // retry once\n    } else {\n        throw e;\n    }\n}","preventionTips":["Unset proxy env vars in the test JVM environment.","Use official couchbase images and current Testcontainers versions.","Check container logs / curl the endpoint on failure.","Ensure the host has enough memory so the server doesn't error mid-startup."],"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"}