{"record":{"id":"35c8e51d970d3530","repo":"elastic/elasticsearch","slug":"unable-to-convert-to-double","errorCode":null,"errorMessage":"unable to convert [{}] to double","messagePattern":"unable to convert \\[(.+?)\\] to double","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java","lineNumber":68,"sourceCode":"            public Object convert(Object value) {\n                try {\n                    String strValue = value.toString();\n                    if (strValue.startsWith(\"0x\") || strValue.startsWith(\"-0x\")) {\n                        return Long.decode(strValue);\n                    }\n                    return Long.parseLong(strValue);\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"unable to convert [\" + value + \"] to long\", e);\n                }\n            }\n        },\n        DOUBLE {\n            @Override\n            public Object convert(Object value) {\n                try {\n                    return Double.parseDouble(value.toString());\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"unable to convert [\" + value + \"] to double\", e);\n                }\n            }\n        },\n        FLOAT {\n            @Override\n            public Object convert(Object value) {\n                try {\n                    return Float.parseFloat(value.toString());\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"unable to convert [\" + value + \"] to float\", e);\n                }\n            }\n        },\n        BOOLEAN {\n            @Override\n            public Object convert(Object value) {\n                if (value.toString().equalsIgnoreCase(\"true\")) {\n                    return true;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java#L50-L86","documentation":"ConvertProcessor.Type.DOUBLE.convert wraps NumberFormatException from Double.parseDouble on value.toString(). Double.parseDouble is stricter than many users expect: it rejects trailing characters, leading/trailing whitespace, and locale-specific separators. The offending value is interpolated into the message.","triggerScenarios":"convert processor with type: double on a value like '1,5' (comma decimal separator), '12 USD', 'abc', 'NaN-text', or with leading/trailing whitespace. Multi-valued fields fail on the first unparseable element.","commonSituations":"Non-English locales that use ',' as decimal separator; currency strings; values with units ('3.14m'); values with surrounding whitespace that survived sanitization.","solutions":["Strip whitespace, currency symbols, and unit suffixes from the value before convert.","Replace locale decimal separators (',') with '.' upstream if applicable.","Set ignore_missing: true for absent fields; filter empty strings upstream.","Quarantine unparseable values via on_failure."],"exampleFix":"// before — comma decimal separator fails Double.parseDouble\n//   { \"convert\": { \"field\": \"temp\", \"type\": \"double\" } }  // temp = \"36,6\"\n//\n// after — normalize the separator first\n//   { \"script\": { \"source\": \"ctx.temp = ctx.temp.replace(',', '.')\" } },\n//   { \"convert\": { \"field\": \"temp\", \"type\": \"double\" } }","handlingStrategy":"validation","validationCode":"boolean isParsableAsDouble(Object v) {\n    if (v == null) return false;\n    String s = v.toString().trim();\n    try { Double.parseDouble(s); return true; } catch (NumberFormatException ignored) { return false; }\n}","typeGuard":"static boolean isDoubleLike(Object v) {\n    if (v instanceof Number) return true;\n    if (v instanceof String s) {\n        try { Double.parseDouble(s.trim()); return true; } catch (NumberFormatException ignored) { return false; }\n    }\n    return false;\n}","tryCatchPattern":"{\n  \"convert\": {\n    \"field\": \"temp\", \"type\": \"double\",\n    \"on_failure\": [\n      { \"set\": { \"field\": \"ingest.error\", \"value\": \"convert-double\" } },\n      { \"redirect\": { \"pipeline\": \"quarantine\" } }\n    ]\n  }\n}","preventionTips":["Double.parseDouble rejects trailing characters — strip units, currency, and whitespace upstream.","Replace locale decimal separators (',') with '.' before convert.","Filter empty strings; set ignore_missing: true if the field may be absent."],"tags":["ingest","convert","type-coercion","parsing","locale"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}