{"record":{"id":"8d7d79e3e86be59b","repo":"elastic/elasticsearch","slug":"failed-to-parse","errorCode":null,"errorMessage":"failed to parse [{}]","messagePattern":"failed to parse \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/core/src/main/java/org/elasticsearch/core/TimeValue.java","lineNumber":431,"sourceCode":"            final long value = Long.parseLong(s);\n            if (value < -1) {\n                // -1 is magic, but reject any other negative values\n                throw new IllegalArgumentException(\n                    \"failed to parse setting [\"\n                        + settingName\n                        + \"] with value [\"\n                        + initialInput\n                        + \"] as a time value: negative durations are not supported\"\n                );\n            }\n            return value;\n        } catch (final NumberFormatException e) {\n            try {\n                @SuppressWarnings(\"unused\")\n                final double ignored = Double.parseDouble(s);\n                throw new IllegalArgumentException(\"failed to parse [\" + initialInput + \"], fractional time values are not supported\", e);\n            } catch (final NumberFormatException ignored) {\n                throw new IllegalArgumentException(\"failed to parse [\" + initialInput + \"]\", e);\n            }\n        }\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n\n        return this.compareTo(((TimeValue) o)) == 0;\n    }\n\n    @Override\n    public int hashCode() {\n        return Double.hashCode(((double) duration) * timeUnit.toNanos(1));\n    }\n\n    public static long nsecToMSec(long ns) {","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/core/src/main/java/org/elasticsearch/core/TimeValue.java#L413-L449","documentation":"Thrown by TimeValue.parse as the final fallback when the numeric prefix of a time value is neither a valid long nor a valid double. The chained NumberFormatException (from the Long attempt) is the cause. This is the catch-all for non-numeric garbage where a unit suffix was recognized but the magnitude was not parseable.","triggerScenarios":"Supplying a time value whose unit suffix is recognized (s, ms, m, h, d, nanos, micros) but whose numeric portion is non-numeric, e.g. \"abcs\", \"--ms\", \"NaNs\", \"1es\". Fires at TimeValue.java:431 after both Long and Double parsing fail.","commonSituations":"A leading stray character (whitespace handled, but symbols not), an embedded unit, a copy-paste that includes a non-breaking space or comment, a templating system that left a placeholder unsubstituted (\"${TIMEOUT}s\").","solutions":["Inspect the original input echoed in the message — it contains a non-numeric magnitude for a recognized unit.","Strip non-ASCII whitespace and stray symbols; ensure the value matches ^-?\\d+(\\.[0-9]+)?[a-z]+$ before parsing.","If the value comes from a template, confirm the placeholder was substituted and is not the literal '${...}' string.","Replace the value with a clean integer + unit, e.g. \"30s\"."],"exampleFix":"// before\nString t = \"${timeout}s\"; // unsubstituted placeholder\n\n// after\nString t = \"30s\";","handlingStrategy":"try-catch","validationCode":"// Strict whitelist before TimeValue.parseTimeValue\nprivate static final Pattern STRICT_TV =\n    Pattern.compile(\"^(?:-1|0+|-?\\\\d+(?:ns|us|micros|ms|s|m|h|d))$\");\nboolean safe(String s) { return s != null && STRICT_TV.matcher(s.trim().toLowerCase(Locale.ROOT)).matches(); }","typeGuard":"static boolean isParsableTimeValue(String s) {\n    if (s == null) return false;\n    String n = s.trim().toLowerCase(Locale.ROOT);\n    return n.equals(\"-1\") || n.matches(\"0+\") || n.matches(\"-?\\\\d+(ns|us|micros|ms|s|m|h|d)\");\n}","tryCatchPattern":"try {\n    return TimeValue.parseTimeValue(raw, setting);\n} catch (IllegalArgumentException e) {\n    log.warn(\"ignoring unparsable time value for [{}]: [{}]\", setting, raw);\n    return defaultValue; // only if a documented default is acceptable; otherwise rethrow","preventionTips":["Treat time-value parsing as an untrusted input boundary: validate before forwarding.","Watch for unsubstituted template placeholders ('${x}') in config-loaded strings.","Strip non-ASCII whitespace before parsing.","Unit-test config parsing with garbage inputs to confirm error messages are clear."],"tags":["time-value","settings","configuration","parse","invalid-input","elasticsearch-core"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}