{"record":{"id":"8726a56cfbe4390f","repo":"apache/seatunnel","slug":"create-index-failed","errorCode":"CREATE_INDEX_FAILED","errorMessage":"PUT ${endpoint} response status code=%d","messagePattern":"PUT (.+?) response status code=(.+?)","errorType":"error_code","errorClass":"EasysearchConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/client/EasysearchClient.java","lineNumber":523,"sourceCode":"                        EasysearchConnectorErrorCode.LIST_INDEX_FAILED,\n                        String.format(\n                                \"GET %s response status code=%d\",\n                                endpoint, response.getStatusLine().getStatusCode()));\n            }\n        } catch (IOException ex) {\n            throw new EasysearchConnectorException(\n                    EasysearchConnectorErrorCode.LIST_INDEX_FAILED, ex);\n        }\n    }\n\n    // todo: We don't support set the index mapping now.\n    public void createIndex(String indexName) {\n        String endpoint = String.format(\"/%s\", indexName);\n        Request request = new Request(\"PUT\", endpoint);\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new EasysearchConnectorException(\n                        EasysearchConnectorErrorCode.CREATE_INDEX_FAILED,\n                        \"PUT \" + endpoint + \" response null\");\n            }\n            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {\n                throw new EasysearchConnectorException(\n                        EasysearchConnectorErrorCode.CREATE_INDEX_FAILED,\n                        String.format(\n                                \"PUT %s response status code=%d\",\n                                endpoint, response.getStatusLine().getStatusCode()));\n            }\n        } catch (IOException ex) {\n            throw new EasysearchConnectorException(\n                    EasysearchConnectorErrorCode.CREATE_INDEX_FAILED, ex);\n        }\n    }\n\n    public void dropIndex(String tableName) {\n        String endpoint = String.format(\"/%s\", tableName);","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/client/EasysearchClient.java#L505-L541","documentation":"createIndex PUTs /{indexName} and throws CREATE_INDEX_FAILED with the HTTP status code when the response status is not 200 (note: Elasticsearch also returns 200 for successful creation, so any other code means rejection). Typical causes are a 400 (invalid index name) or 400 'resource_already_exists_exception' when the index already exists.","triggerScenarios":"Auto-create-index before writing: PUT /{index} rejected with 400 invalid index name (uppercase, invalid chars, too long), 400 index already exists, or 403 insufficient permissions.","commonSituations":"Table name derived from upstream data contains characters illegal for index names (uppercase, '\\/', '?', '\"', '<', '>', '|', ' ', ',', '#'), race between parallel tasks creating the same index, user lacking 'create_index' privilege.","solutions":["Lowercase the index name and strip illegal characters before createIndex","Treat 'resource_already_exists_exception' (400) as success/idempotent — check existence first with a HEAD request or catch and ignore","Grant the user cluster 'create_index' and index 'manage' privileges","Check the status code: 400 name/validation issue, 403 authz issue, 5xx server issue"],"exampleFix":"// before\ncreateIndex(tableName); // tableName = \"MyTable\"\n// after\nString idx = tableName.toLowerCase().replaceAll(\"[\\\\s/?:\\\"<>|,#]\", \"_\");\nif (!indexExists(idx)) createIndex(idx);","handlingStrategy":"try-catch","validationCode":"String idx = indexName.toLowerCase();\nif (!idx.matches(\"[a-z0-9][a-z0-9_.-]*\") || idx.length() > 255) throw new IllegalArgumentException(\"invalid index name: \" + indexName);\ntry { restClient.performRequest(new Request(\"HEAD\", \"/\" + idx)); exists = true; } catch (ResponseException e) { exists = false; }","typeGuard":null,"tryCatchPattern":"try { client.createIndex(index); } catch (EasysearchConnectorException e) { if (e.getMessage().contains(\"resource_already_exists\") || e.getMessage().contains(\"400\")) { log.info(\"index exists, continuing\"); } else throw e; }","preventionTips":["Normalize table names to lowercase, no illegal chars, ≤255 bytes","Make index creation idempotent (check existence or tolerate already-exists 400)","Grant create_index/manage privileges to the job user","Avoid parallel tasks racing to create the same index"],"tags":["http","status-code","create-index","easysearch"],"backgroundTag":"http-non-200-response","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}