{"record":{"id":"e80bbd2e1ebcd5a3","repo":"theonedev/onedev","slug":"invalid-working-period","errorCode":null,"errorMessage":"Invalid working period","messagePattern":"Invalid working period","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/model/support/issue/TimeTrackingSetting.java","lineNumber":119,"sourceCode":"\t\treturn new ArrayList<>(choices);\n\t}\n\n\tpublic Usage onDeleteLink(String linkName) {\n\t\tUsage usage = new Usage();\n\t\tif (linkName.equals(aggregationLink))\n\t\t\tusage.add(_T(\"time aggregation link\"));\n\t\treturn usage;\n\t}\n\n\tpublic void onRenameLink(String oldName, String newName) {\n\t\tif (oldName.equals(aggregationLink))\n\t\t\taggregationLink = newName;\n\t}\n\n\tpublic int parseWorkingPeriod(String period) {\n\t\tperiod = StringUtils.deleteWhitespace(period);\n\t\tif (StringUtils.isBlank(period))\n\t\t\tthrow new ValidationException(_T(\"Invalid working period\"));\n\n\t\tif (period.equals(\"0\"))\n\t\t\treturn 0;\n\n\t\tif (useHoursAndMinutesOnly) {\n\t\t\tMatcher matcher = HOURS_AND_MINUTES_ONLY_WORKING_PERIOD_PATTERN.matcher(period);\n\t\t\tif (!matcher.matches())\n\t\t\t\tthrow new ValidationException(_T(\"Invalid working period\"));\n\t\n\t\t\tint minutes = 0;\t\n\t\t\tif (matcher.group(1) != null) {\n\t\t\t\tint hours = Integer.parseInt(StringUtils.stripEnd(matcher.group(1), \"h\"));\n\t\t\t\tminutes += hours*60;\n\t\t\t}\n\t\n\t\t\tif (matcher.group(2) != null)\n\t\t\t\tminutes += Integer.parseInt(StringUtils.stripEnd(matcher.group(2), \"m\"));\n\t","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/support/issue/TimeTrackingSetting.java#L101-L137","documentation":"TimeTrackingSetting.parseWorkingPeriod(String) parses a user-entered working period (e.g. '2d 4h', '1h 30m') into an amount using configured unit patterns. Blank input throws ValidationException 'Invalid working period', as does input that fails the configured pattern set. This is user-facing input validation for issue time tracking.","triggerScenarios":"Entering an empty/whitespace-only working period, or a value not matching the enabled units' patterns (especially when useHoursAndMinutesOnly restricts to 'Xh Ym' format) when submitting time tracking on an issue.","commonSituations":"User types '2 days' when only h/m format is enabled; includes unsupported units (e.g. weeks/months pattern disabled); locale-specific number or spacing oddities; submitting the form with an empty field.","solutions":["Enter the period in the format shown on the issue form, e.g. '2d 4h' or, if hours-and-minutes-only is enabled, '2h 30m'","If other time units (weeks, months) are needed, enable them in Administration → Issue Settings → Time Tracking","For '0', use the literal '0' which is accepted as a special case"],"exampleFix":"// before (invalid input with hours/minutes-only setting)\nissue.getOwnTimeSpent(); // user entered \"2 days\"\n// after: enter a valid period\n\"2h 30m\"   // or enable day/week units in time tracking settings","handlingStrategy":"validation","validationCode":"// client-side check before submit\nif (periodText.isBlank()) throw new ValidationException(\"Working period required\");\n// server-side pre-check\nboolean blank = StringUtils.isBlank(StringUtils.deleteWhitespace(periodText));","typeGuard":null,"tryCatchPattern":"try {\n    int minutes = timeTrackingSetting.parseWorkingPeriod(periodText);\n} catch (ValidationException e) {\n    errors.add(\"Invalid working period; use e.g. 2d 4h or 1h 30m\");\n}","preventionTips":["Show the accepted format hint next to the input field","Match input units to the enabled units in Time Tracking settings","Trim/normalize whitespace before submission"],"tags":["time-tracking","input-validation","issues"],"backgroundTag":"invalid-argument-format","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}