{"record":{"id":"b951b355148d4002","repo":"elastic/elasticsearch","slug":"ignore-value-should-be-a-number-found-instea","errorCode":null,"errorMessage":"ignore value should be a number, found [{}] instead","messagePattern":"ignore value should be a number, found \\[(.+?)\\] instead","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"client/rest/src/main/java/org/elasticsearch/client/RestClient.java","lineNumber":875,"sourceCode":"        if (ignoreString == null) {\n            if (HttpHead.METHOD_NAME.equals(requestMethod)) {\n                // 404 never causes error if returned for a HEAD request\n                ignoreErrorCodes = Collections.singleton(404);\n            } else {\n                ignoreErrorCodes = Collections.emptySet();\n            }\n        } else {\n            String[] ignoresArray = ignoreString.split(\",\");\n            ignoreErrorCodes = new HashSet<>();\n            if (HttpHead.METHOD_NAME.equals(requestMethod)) {\n                // 404 never causes error if returned for a HEAD request\n                ignoreErrorCodes.add(404);\n            }\n            for (String ignoreCode : ignoresArray) {\n                try {\n                    ignoreErrorCodes.add(Integer.valueOf(ignoreCode));\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"ignore value should be a number, found [\" + ignoreString + \"] instead\", e);\n                }\n            }\n        }\n        return ignoreErrorCodes;\n    }\n\n    private static class ResponseOrResponseException {\n        private final Response response;\n        private final ResponseException responseException;\n\n        ResponseOrResponseException(Response response) {\n            this.response = Objects.requireNonNull(response);\n            this.responseException = null;\n        }\n\n        ResponseOrResponseException(ResponseException responseException) {\n            this.responseException = Objects.requireNonNull(responseException);\n            this.response = null;","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/client/rest/src/main/java/org/elasticsearch/client/RestClient.java#L857-L893","documentation":"Thrown while parsing the comma-separated list of HTTP status codes passed via the RequestOptions 'ignore' parameter. Each token must parse as an Integer; any non-numeric token raises IllegalArgumentException chaining the NumberFormatException. HEAD requests implicitly add 404 to the ignore set beforehand.","triggerScenarios":"Building RequestOptions with setParameter(\"ignore\", \"404,500\") where one token is not an integer (e.g. \"4xx\", \"\", \"not_found\").","commonSituations":"Copy-pasting symbolic error names instead of codes; trailing comma producing an empty token; whitespace-only token; misusing the option as a free-form list.","solutions":["Provide only integer status codes separated by commas, e.g. \"404,500,409\".","Trim whitespace and avoid trailing commas in the ignore string.","Use the typed API (RequestOptions.Builder) where available rather than hand-built strings."],"exampleFix":"// before\nRequestOptions opts = RequestOptions.DEFAULT.toBuilder()\n    .putHeader(\"Accept\", \"application/json\").build();\nRequest req = new Request(\"GET\", \"/missing\");\nreq.getOptions().toBuilder().addParameter(\"ignore\", \"not_found\");\n// after\nRequestOptions opts = RequestOptions.DEFAULT.toBuilder()\n    .putHeader(\"Accept\", \"application/json\").build();\nRequest req = new Request(\"GET\", \"/missing\");\nreq.getOptions().toBuilder().addParameter(\"ignore\", \"404\");","handlingStrategy":"validation","validationCode":"static Set<Integer> parseIgnore(String s) {\n    Set<Integer> out = new HashSet<>();\n    for (String t : s.split(\",\")) {\n        String v = t.trim();\n        if (v.isEmpty()) continue;\n        out.add(Integer.parseInt(v)); // throws NumberFormatException -> convert to IllegalArgumentException upstack\n    }\n    return out;\n}","typeGuard":null,"tryCatchPattern":"try { RequestOptions b = base.toBuilder().addParameter(\"ignore\", codes).build(); }\ncatch (IllegalArgumentException e) { /* user-supplied ignore list bad: surface as 400 */ }","preventionTips":["Build the ignore string only from int constants in your code.","Strip whitespace and skip empties before joining codes."],"tags":["rest-client","request-options","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}