RFC3339 year 0000 rejected by date-time format validation

Aberta
#1,465 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 6 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
python
Domínio
backend

Direção de pesquisa

Comece com a reprodução mínima de validate(...) e compare-a com a chamada direta a rfc3339-validator descrita na issue. Rastreie como a validação do formato date-time chega a essa dependência; em seguida, verifique o resultado esperado para 0000-01-01T00:00:00Z de acordo com a RFC3339 e documente ou teste o comportamento resultante.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Needs Test Upstream

Summary

Validation of the date-time format rejects timestamps containing year 0000, even though the RFC3339 grammar allows any four-digit year.

Example timestamp:

0000-01-01T00:00:00Z

Context

During interoperability testing of JSON Schema date-time format validation across multiple implementations, I observed that this value is accepted by several validators but rejected by python-jsonschema. Further investigation suggests the behavior originates from the rfc3339-validator dependency used internally for date-time checking.

Specification Reference

RFC3339 defines the year component using the following grammar:

date-fullyear = 4DIGIT

Reference:
https://www.rfc-editor.org/rfc/rfc3339

Because the grammar explicitly permits any four digits, the year 0000 is syntactically valid according to the RFC.

Minimal Reproduction

from jsonschema import validate

schema = {
    "type": "string",
    "format": "date-time"
}

validate("0000-01-01T00:00:00Z", schema)

Observed Behavior

The validator raises a ValidationError, indicating the instance is not considered a valid date-time.

Expected Behavior

The timestamp should be accepted as syntactically valid according to the RFC3339 grammar.

Cross-Implementation Observation

During interoperability testing:

  • Hyperjump JSON Schema accepts the timestamp.
  • jsonschema-rs accepts the timestamp.
  • python-jsonschema rejects the timestamp when format validation is enabled.
  • Direct calls to rfc3339-validator also reject the timestamp.

This indicates that the behavior likely originates from the underlying RFC3339 validation library used by the Python stack.

Possible Cause

The underlying validation library appears to reject year 0000, possibly due to limitations in date parsing logic or assumptions about supported calendar ranges.

Question

Is this behavior intentional, or would it be preferable for date-time validation to align strictly with the RFC3339 grammar? If the limitation originates in the underlying dependency, clarification in documentation may help users understand the behavior.

Linguagem predominante
Python
Estrelas
5k
Forks
741
Merge médio
4d 17h
PRs com merge (30d)
6

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-jsonschema/jsonschema

Todas as issues de python-jsonschema/jsonschema

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.