#1807·luxon

Duration.fromISO("P"/"PT"/"-P") parses as a valid zero duration, causing Interval overlaps()/merge() to silently ignore the interval

Author: manqingzhouCreated Sep 21, 2026Updated Sep 21, 2026

Describe the bug

luxon's ISO-8601 duration regex (isoDuration in src/impl/regexParser.js) makes every component group optional, including the whole T clause. That means the bare strings "P", "PT", and "-P" — none of which specify any actual duration component, and none of which are valid ISO 8601 (which requires at least one designator) — match the grammar. extractISODuration then returns an object whose fields are all undefined, which is still truthy, so Duration.fromISO treats it as a successful parse and normalizes it to a valid zero-length Duration.

Fed into Interval.fromISO("<start>/P") (a standard, documented interval-string form), this produces a structurally valid, zero-length interval — isValid: true. Since isValid is the library's own documented guard for "is this safe to use," and it doesn't fire here, overlaps()/merge()/contains() silently treat this interval as a no-op: a "blackout"/deny/maintenance window expressed as "<start>/P" reports no overlap with anything, and merge() drops it entirely.

To Reproduce

javascript
import { Duration, Interval } from 'luxon';

console.log(Duration.fromISO('P').isValid);   // true (should be false)
console.log(Duration.fromISO('PT').isValid);  // true
console.log(Duration.fromISO('-P').isValid);  // true

const maintenance = Interval.fromISO('2024-06-01T09:00Z/P');
console.log(maintenance.isValid, maintenance.isEmpty()); // true true

const booking = Interval.fromISO('2024-06-01T09:00Z/2024-06-01T10:00Z');
console.log(maintenance.overlaps(booking));               // false — no conflict detected
console.log(Interval.merge([maintenance, booking]).length); // 1 — maintenance window silently dropped

Verified against the actual 3.7.2 source; output matches exactly.

Actual vs Expected behavior

Actual: "P"/"PT"/"-P" parse as valid zero durations; an interval built from one is isValid: true and silently disappears from overlaps/merge checks. Expected: per ISO 8601, a duration must specify at least one component — Duration.fromISO("P") (and "PT"/"-P") should produce an Invalid Duration.

Desktop (please complete the following information):

  • Luxon version: 3.7.2 (current latest; verified against source at GitHub tag 3.7.2)
  • Node: v24.16.0

Additional context

Suggested fix: in extractISODuration, detect the "every capture group is undefined" case and return [null] instead, so these strings become Invalid Durations. Given some callers may legitimately want zero-length intervals to be representable, it's probably not right to change Interval.fromDateTimes itself — but it would help to document (or provide an explicit conflictsWith()/strict variant of overlaps) that isEmpty() intervals need special handling in any deny/window-conflict logic, since the current behavior is easy to miss (an Interval can be simultaneously isValid: true and isEmpty(): true, and none of overlaps/contains/engulfs/merge special-case that).