Draft-3 time format accepts unpadded components and non-ASCII digits

Open Beginner friendly
#1,610 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by locating the Draft 3 time format checker and its tests; the issue does not name their file paths. Check how parsing handles unpadded components and Unicode digits, then compare its behavior with the stricter date and UUID checkers. Done means malformed examples are rejected, padded times are accepted, and non-string behavior is preserved.

Written by the indexing model from the issue text.

Description

With format checking explicitly enabled, Draft3Validator accepts malformed time strings:

from jsonschema import Draft3Validator
v = Draft3Validator({"format": "time"}, format_checker=Draft3Validator.FORMAT_CHECKER)
v.is_valid("1:2:3")        # True
v.is_valid("01:0\u0662:03")  # True

The draft-3 specification describes time as hh:mm:ss: https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5.23 . Python strptime accepts missing padding and Unicode decimal digits, so parsing successfully does not establish the required textual format. The date and UUID format checkers already enforce stricter textual representations.

Expected: reject these malformed strings while accepting padded times and preserving non-string behavior. Five malformed-value subtests fail on unchanged main. A focused fix compares the parsed time's canonical HH:MM:SS representation with the original input.

Impact: invalid time data passes explicitly requested format validation in applications using draft-3 schemas. I assess this as medium severity, not a maintainer-assigned severity label. Codex assisted with investigation, implementation and tests.

Dominant language
Python
Stars
5k
Forks
741
Avg merge
4d 17h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-jsonschema/jsonschema

All issues in python-jsonschema/jsonschema

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.