{"record":{"id":"4a8390938c447715","repo":"alibaba/arthas","slug":"s-is-not-a-valid-timespan-shoule-be-numeric-v","errorCode":null,"errorMessage":"'{s}' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20s. Valid units s, m, h and d.","messagePattern":"'(.+?)' is not a valid timespan\\. Shoule be numeric value followed by a unit, i\\.e\\. 20s\\. Valid units s, m, h and d\\.","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/com/taobao/arthas/core/command/basic1000/JFRCommand.java","lineNumber":375,"sourceCode":"            }\n        }\n    }\n\n    public long parseTimespan(String s) throws Exception {\n        s = s.toLowerCase();\n        if (s.endsWith(\"s\")) {\n            return TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);\n        } else if (s.endsWith(\"m\")) {\n            return 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);\n        } else if (s.endsWith(\"h\")) {\n            return 60 * 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);\n        } else if (s.endsWith(\"d\")) {\n            return 24 * 60 * 60 * TimeUnit.NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), TimeUnit.SECONDS);\n        } else {\n            try {\n                return Long.parseLong(s);\n            } catch (NumberFormatException var2) {\n                throw new NumberFormatException(\"'\" + s + \"' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20s. Valid units s, m, h and d.\");\n            }\n        }\n    }\n\n    private List<Recording> findRecordingByState(String state) {\n        List<Recording> resultRecordingList = new ArrayList<Recording>();\n        Collection<Recording> recordingList = recordings.values();\n        for (Recording recording : recordingList) {\n            if (recording.getState().toString().toLowerCase().equals(state)) {\n                resultRecordingList.add(recording);\n            }\n        }\n        return resultRecordingList;\n    }\n\n    private void printRecording(Recording recording) {\n        String format = \"Recording: recording=\" + recording.getId() + \" name=\" + recording.getName() + \"\";\n        result.setJfrOutput(format);","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/basic1000/JFRCommand.java#L357-L393","documentation":"Thrown as NumberFormatException by JFRCommand.parseTimespan when the input does not end in s/m/h/d and cannot be parsed as a bare number. Note: m here means minutes (time), not megabytes — distinct from parseSize. The error message has a known typo ('Shoule').","triggerScenarios":"Pass a --duration value with an unsupported unit (e.g. '30sec', '1hr', '2w', '1.5h'), or a non-numeric token. Decimals and multi-char units are not accepted; only single chars s/m/h/d (or a bare number).","commonSituations":"User types '30min' instead of '30m'; uses '1hr' instead of '1h'; uses decimals; confuses m (minutes) with the size m (megabytes).","solutions":["Use a single lowercase unit char with an integer: 30s, 5m, 2h, 1d, or a bare number.","Avoid multi-char units (sec/min/hr) and decimals.","Remember the unit vocabulary is s/m/h/d only."],"exampleFix":"// before\njfr --duration 30min\n\n// after\njfr --duration 30m","handlingStrategy":"validation","validationCode":"if (!s.matches(\"\\\\d+[smhdSMHD]?\")) {\n    // reject before calling parseTimespan\n}","typeGuard":"static boolean isValidTimespan(String s) { return s != null && s.matches(\"(?i)\\\\d+[smhd]?\"); }","tryCatchPattern":"try { long ns = cmd.parseTimespan(s); } catch (NumberFormatException e) { /* prompt user for a valid duration like 30m */ }","preventionTips":["Use single-char units (s/m/h/d) with integers.","Remember m = minutes here, not megabytes.","Avoid multi-char units (sec/min/hr) and decimals."],"tags":["jfr","user-input","parsing","configuration"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}