{"record":{"id":"148c0f0cefdd6cb3","repo":"apache/flink","slug":"text-does-not-start-with-a-number-and-is-not-a-va","errorCode":null,"errorMessage":"text does not start with a number, and is not a valid ISO-8601 duration format: ${trimmed}","messagePattern":"text does not start with a number, and is not a valid ISO-8601 duration format: (.+?)","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/TimeUtils.java","lineNumber":91,"sourceCode":"        char current;\n        while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {\n            pos++;\n        }\n\n        final String number = trimmed.substring(0, pos);\n        final String unitLabel = trimmed.substring(pos).trim().toLowerCase(Locale.US);\n\n        if (number.isEmpty()) {\n            try {\n                // Fall back to parse ISO-8601 duration format\n                Duration parsedDuration = Duration.parse(trimmed);\n                if (parsedDuration.isNegative()) {\n                    // Don't support negative duration which is consistent with before format\n                    throw new NumberFormatException(\"negative duration is not supported\");\n                }\n                return parsedDuration;\n            } catch (DateTimeParseException e) {\n                throw new NumberFormatException(\n                        \"text does not start with a number, and is not a valid ISO-8601 duration format: \"\n                                + trimmed);\n            }\n        }\n\n        final BigInteger value;\n        try {\n            value = new BigInteger(number); // this throws a NumberFormatException\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\n                    \"The value '\" + number + \"' cannot be represented as an integer number.\", e);\n        }\n\n        final ChronoUnit unit;\n        if (unitLabel.isEmpty()) {\n            unit = ChronoUnit.MILLIS;\n        } else {\n            unit = LABEL_TO_UNIT_MAP.get(unitLabel);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/TimeUtils.java#L73-L109","documentation":"TimeUtils.parseDuration reads a leading run of digits as the numeric part; if that run is empty (text does not start with a number) it tries ISO-8601 via Duration.parse. When that also fails with DateTimeParseException, the text is rejected with this NumberFormatException listing the offending input.","triggerScenarios":"Calling TimeUtils.parseDuration with text that neither starts with a digit nor is valid ISO-8601, e.g. \"abc\", \"ten seconds\", \" s\", \"P\" (incomplete ISO period), or \"T10S\" (missing P prefix).","commonSituations":"Typos in duration config keys (\"1sec\" vs \"1 s\" is fine but \"sec\" alone is not), missing unit prefix P in ISO strings, localized or spelled-out durations, empty string values.","solutions":["Rewrite the value as <number><optional space><unit>, e.g. \"10 s\", \"5 min\", \"1 h\", or a full ISO-8601 duration like \"PT10S\".","If the value came from a variable, make sure it was not empty or null-coalesced to \"\".","Check for a missing 'P' prefix when using ISO-8601 form (PT10S, not T10S)."],"exampleFix":"# before\ncheckpoint.interval=ten-seconds\n\n# after\ncheckpoint.interval=10 s","handlingStrategy":"validation","validationCode":"String t = text.trim();\nboolean numberFirst = !t.isEmpty() && Character.isDigit(t.charAt(0));\nboolean iso = t.startsWith(\"P\");\nif (!numberFirst && !iso) throw new IllegalArgumentException(\"Not a number+unit or ISO-8601 duration: \" + t);\nTimeUtils.parseDuration(t);","typeGuard":null,"tryCatchPattern":"try { TimeUtils.parseDuration(t); }\ncatch (NumberFormatException e) { return defaultDuration; } // only if a safe default is acceptable","preventionTips":["Prefer the '<n> <unit>' form (\"10 s\") for hand-written config.","Remember ISO-8601 durations must start with 'P'.","Trim inputs and reject empty strings before parsing."],"tags":["configuration","duration","parsing","iso-8601"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}