{"record":{"id":"433549e4dffa0d5e","repo":"elastic/elasticsearch","slug":"cloudid-must-begin-with-a-human-readable-identi","errorCode":null,"errorMessage":"cloudId {} must begin with a human readable identifier followed by a colon","messagePattern":"cloudId (.+?) must begin with a human readable identifier followed by a colon","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"client/rest/src/main/java/org/elasticsearch/client/RestClient.java","lineNumber":163,"sourceCode":"        this.warningsHandler = strictDeprecationMode ? WarningsHandler.STRICT : WarningsHandler.PERMISSIVE;\n        this.compressionEnabled = compressionEnabled;\n        this.metaHeaderEnabled = metaHeaderEnabled;\n        setNodes(nodes);\n    }\n\n    /**\n     * Returns a new {@link RestClientBuilder} to help with {@link RestClient} creation.\n     * Creates a new builder instance and sets the nodes that the client will send requests to.\n     *\n     * @param cloudId a valid elastic cloud cloudId that will route to a cluster. The cloudId is located in\n     *                the user console https://cloud.elastic.co and will resemble a string like the following\n     *                optionalHumanReadableName:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRlbGFzdGljc2VhcmNoJGtpYmFuYQ==\n     */\n    public static RestClientBuilder builder(String cloudId) {\n        // there is an optional first portion of the cloudId that is a human readable string, but it is not used.\n        if (cloudId.contains(\":\")) {\n            if (cloudId.indexOf(':') == cloudId.length() - 1) {\n                throw new IllegalStateException(\"cloudId \" + cloudId + \" must begin with a human readable identifier followed by a colon\");\n            }\n            cloudId = cloudId.substring(cloudId.indexOf(':') + 1);\n        }\n\n        String decoded = new String(Base64.getDecoder().decode(cloudId), UTF_8);\n        // once decoded the parts are separated by a $ character.\n        // they are respectively domain name and optional port, elasticsearch id, kibana id\n        String[] decodedParts = decoded.split(\"\\\\$\");\n        if (decodedParts.length != 3) {\n            throw new IllegalStateException(\"cloudId \" + cloudId + \" did not decode to a cluster identifier correctly\");\n        }\n\n        // domain name and optional port\n        String[] domainAndMaybePort = decodedParts[0].split(\":\", 2);\n        String domain = domainAndMaybePort[0];\n        int port;\n\n        if (domainAndMaybePort.length == 2) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/client/rest/src/main/java/org/elasticsearch/client/RestClient.java#L145-L181","documentation":"RestClient.builder(cloudId) accepts an optional human-readable prefix terminated by ':'. If a ':' is present but is the LAST character (nothing follows it), the cloudId is malformed — the Base64 payload that should follow the colon is empty, so parsing cannot proceed.","triggerScenarios":"Passing a cloudId string like 'my-cluster:' (colon with no Base64 after it); a truncated/copy-paste cloudId from the Elastic Cloud console; a cloudId whose prefix colon was added by mistake.","commonSituations":"User copies the human-readable label from Elastic Cloud but misses the Base64 portion; trailing whitespace or newline truncation; manual concatenation that drops the payload.","solutions":["Re-copy the full cloudId from Elastic Cloud console (it contains the Base64 payload after the colon).","Strip the human-readable prefix entirely if you only have the Base64 part — builder accepts a colon-less cloudId too.","Validate the cloudId shape (contains ':' followed by non-empty Base64) before calling builder."],"exampleFix":"// before\nRestClient.builder(\"my-cluster:\"); // empty payload after colon\n// after\nRestClient.builder(\"my-cluster:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRlbGFzdGljc2VhcmNoJGtpYmFuYQ==\");","handlingStrategy":"validation","validationCode":"static boolean cloudIdHasPayload(String cloudId) {\n    int ci = cloudId.indexOf(':');\n    return ci < 0 || ci < cloudId.length() - 1; // colon-less, or colon followed by payload\n}\nif (!cloudIdHasPayload(cloudId)) throw new IllegalArgumentException(\"cloudId missing Base64 payload after colon\");\nRestClient.builder(cloudId);","typeGuard":null,"tryCatchPattern":"try { RestClient.builder(cloudId); } catch (IllegalStateException e) { /* prompt user to re-copy cloudId from Elastic Cloud */ }","preventionTips":["Copy the cloudId verbatim from the Elastic Cloud console 'Cloud ID' field.","Treat the human-readable prefix as optional decoration; the Base64 payload is mandatory.","Validate cloudId shape at config load time."],"tags":["rest-client","cloud-id","config","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}