Skip to content

Timestamp validation accepts impossible values and values without an offset #57

Description

@leoafarias

Summary

_isIsoDateTime (lib/src/spec_rules/concept_rules.dart, unchanged on main) accepts any string that contains T and that DateTime.tryParse accepts. tryParse rolls out-of-range fields over instead of rejecting them, so impossible timestamps pass invalid-generated and invalid-verified:

Value Accepted Parsed as (UTC)
2026-13-40T17:46:35Z yes 2027-02-09T17:46:35Z
2026-09-11T25:61:61Z yes 2026-09-12T02:02:01Z
2026-02-30T10:00:00Z yes 2026-03-02T10:00:00Z
2026-09-11T17:46 (no offset) yes the reader's local time zone

Date-only values are already strict: parseIsoDate round-trips its result and rejects non-canonical spellings. Timestamps have no equivalent check.

Proposal

  • Add one strict timestamp parser, for example parseOkfTimestamp. It would accept the ISO 8601 extended format with an explicit offset, check each field's range, and round-trip the value.

  • Use that parser everywhere a timestamp is read:

    • the invalid-generated / invalid-verified rules
    • OkfGeneration.atDateTime and OkfVerification.isUsable
    • staleness
    • graph metadata

    Today these paths separately accept String or DateTime through _scalarString, _parseDateTime and DateTime.tryParse. One parser simplifies them and makes them agree.

  • Once Adopt OKF spec 62432a0: every timestamp is an ISO 8601 datetime with an explicit offset #56 lands, a missing offset should be reported too, because OKF now requires an explicit one.

The findings stay advisory, as they are today. The fix only makes them fire on invalid values.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions