RFC3339 year 0000 rejected by date-time format validation

未關閉
#1,465 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 6 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python
領域
backend

研究方向

從 validate(...) 的最小重現開始,並將其與 issue 中描述的對 rfc3339-validator 的直接呼叫進行比較。追蹤 date-time 格式驗證如何到達該相依性,然後根據 RFC3339 驗證 0000-01-01T00:00:00Z 的預期結果,並記錄或測試由此產生的行為。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
5k
分支
741
平均合併
4 天 17 小時
30 天內合併 PR
6

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python-jsonschema/jsonschema 的其他 Issue

查看 python-jsonschema/jsonschema 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。