{"record":{"id":"ca86c6217243ccf8","repo":"testcontainers/testcontainers-java","slug":"message-response-body-body","errorCode":null,"errorMessage":"message: response, body=body","messagePattern":"message: response, body=body","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java","lineNumber":794,"sourceCode":"\n    /**\n     * Helper method to check if the response is successful and release the body if needed.\n     *\n     * @param response the response to check.\n     * @param message the message that should be part of the exception of not successful.\n     */\n    private void checkSuccessfulResponse(final Response response, final String message) {\n        if (!response.isSuccessful()) {\n            String body = null;\n            if (response.body() != null) {\n                try {\n                    body = response.body().string();\n                } catch (IOException e) {\n                    logger().debug(\"Unable to read body of response: {}\", response, e);\n                }\n            }\n\n            throw new IllegalStateException(message + \": \" + response + \", body=\" + (body == null ? \"<null>\" : body));\n        }\n    }\n\n    /**\n     * Checks if already running and if so raises an exception to prevent too-late setters.\n     */\n    private void checkNotRunning() {\n        if (isRunning()) {\n            throw new IllegalStateException(\"Setter can only be called before the container is running\");\n        }\n    }\n\n    /**\n     * Helper method to perform a request against a couchbase server HTTP endpoint.\n     *\n     * @param port the (unmapped) original port that should be used.\n     * @param path the relative http path.\n     * @param method the http method to use.","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java#L776-L812","documentation":"checkSuccessfulResponse() is Testcontainers' guard for Couchbase REST calls made during container configuration. When the management API returns a non-success status, it throws IllegalStateException containing the request message, the HTTP response object, and (when readable) the response body, so the actual server-side failure reason is surfaced.","triggerScenarios":"Any configuration REST call failing: renameNode, initializeServices (unsupported service for edition), setMemoryQuotas (quota below server minimum), configureAdminUser, configureExternalPorts, configureIndexer — i.e. any 4xx/5xx from the Couchbase management API during startup.","commonSituations":"Requesting a service the edition doesn't support; quota conflicts between buckets/services; reusing a container volume with conflicting node names; calling setters after the container already started (partially configured).","solutions":["Read the 'body=' part of the message — it contains Couchbase's own error explanation (e.g. quota too small, service unsupported).","Verify quotas meet service minimums and services are supported by your image edition.","Use a fresh container/volume; avoid reusing state from previous runs that conflict with rename/external-port configuration.","Ensure all with* configuration happens before container.start()."],"exampleFix":"// before\ncontainer.withServiceQuota(CouchbaseService.SEARCH, 100).start(); // server rejects quota\n// after\ncontainer.withServiceQuota(CouchbaseService.SEARCH, CouchbaseService.SEARCH.getMinimumQuotaMb()).start();","handlingStrategy":"try-catch","validationCode":"// before start(): validate all quotas and services\nfor (Map.Entry<CouchbaseService,Integer> e : quotas.entrySet()) {\n    if (!e.getKey().hasQuota() || e.getValue() < e.getKey().getMinimumQuotaMb()) {\n        throw new IllegalArgumentException(\"bad quota for \" + e.getKey());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    container.start();\n} catch (IllegalStateException e) {\n    // message embeds 'body=<server error>' — parse/log it for the root cause\n    String body = e.getMessage().replaceAll(\".*body=\", \"\");\n    logger.error(\"Couchbase config API rejected a call: {}\", body, e);\n    throw e;\n}","preventionTips":["Always read the body= section of the message — it holds Couchbase's error reason.","Configure everything via with* methods before start(); never mutate a running container.","Match services and quotas to the image edition.","Start from a fresh container/volume on each run to avoid rename/port conflicts."],"tags":["testcontainers","couchbase","http","startup"],"backgroundTag":"http-error-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"}