theonedev/onedev · warning · ValidationException
Invalid working period
Error message
Invalid working period
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/model/support/issue/TimeTrackingSetting.java:119
return new ArrayList<>(choices);
}
public Usage onDeleteLink(String linkName) {
Usage usage = new Usage();
if (linkName.equals(aggregationLink))
usage.add(_T("time aggregation link"));
return usage;
}
public void onRenameLink(String oldName, String newName) {
if (oldName.equals(aggregationLink))
aggregationLink = newName;
}
public int parseWorkingPeriod(String period) {
period = StringUtils.deleteWhitespace(period);
if (StringUtils.isBlank(period))
throw new ValidationException(_T("Invalid working period"));
if (period.equals("0"))
return 0;
if (useHoursAndMinutesOnly) {
Matcher matcher = HOURS_AND_MINUTES_ONLY_WORKING_PERIOD_PATTERN.matcher(period);
if (!matcher.matches())
throw new ValidationException(_T("Invalid working period"));
int minutes = 0;
if (matcher.group(1) != null) {
int hours = Integer.parseInt(StringUtils.stripEnd(matcher.group(1), "h"));
minutes += hours*60;
}
if (matcher.group(2) != null)
minutes += Integer.parseInt(StringUtils.stripEnd(matcher.group(2), "m"));
View on GitHub (pinned to d44925c47c)
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
Example fix
// before (invalid input with hours/minutes-only setting) issue.getOwnTimeSpent(); // user entered "2 days" // after: enter a valid period "2h 30m" // or enable day/week units in time tracking settings
Defensive patterns
Strategy: validation
Validate before calling
// client-side check before submit
if (periodText.isBlank()) throw new ValidationException("Working period required");
// server-side pre-check
boolean blank = StringUtils.isBlank(StringUtils.deleteWhitespace(periodText)); Try / catch
try {
int minutes = timeTrackingSetting.parseWorkingPeriod(periodText);
} catch (ValidationException e) {
errors.add("Invalid working period; use e.g. 2d 4h or 1h 30m");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Time tracking needs to be enabled for the project
- An active subscription is required for this feature
- Title is required
- An active subscription is required for this feature
- Issue schedule permission required to set own estimated time
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/e80bbd2e1ebcd5a3.
Report an issue: GitHub.