Date and DateTime selectors accept invalid components (Date(2023, 2, 29), month 13, day 32); later operations give NaN
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
Start in src/elm/datetime.ts, where the issue identifies the Date and DateTime expressions as passing evaluated components to datatype constructors without validation; then inspect the DT.Date and DT.DateTime constructors and existing date string validation. Run the relevant date and datetime tests, and add coverage for invalid computed components such as a non-leap-year February 29, month 13, and day 32. Done means these selectors no longer produce invalid date values that later yield NaN.
索引モデルが issue の本文から書いたものです。
説明
The Date and DateTime selectors accept components that do not form a calendar date, such as 29 February in a non-leap year, month 13 or day 32. The resulting value then breaks later operations, producing NaN.
library InvalidDateComponents version '1.0.0'
define Feb29NonLeap: Date(2023, 2, 29) // 2023-02-29
define Month13: Date(2023, 13, 1) // 2023-13-01
define Day32: Date(2023, 1, 32) // 2023-01-32
define DateTimeFeb29NonLeap: DateTime(2023, 2, 29, 0, 0, 0, 0, 0) // 2023-02-29T00:00:00.000+00:00
define Feb29PlusOneDay: Date(2023, 2, 29) + 1 day // a Date that prints as 0NaN-NaN-NaN
define Feb29EqualsMar01: Date(2023, 2, 29) = @2023-03-01 // false
define DaysFeb28ToFeb29: days between @2023-02-28 and Date(2023, 2, 29) // Uncertainty with NaN bounds
Expected: these selectors should not return a Date or DateTime value.
- The reference Java/Kotlin engine throws for each of them ("Invalid date 'February 29' as '2023' is not a leap year", "Invalid date: month must be a number between 1 and 12, got 13", "day of month must be a number between 1 and 31, got 32").
- The translator rejects the equivalent literal:
@2023-02-29gives "Invalid date-time input (2023-02-29)". - Appendix B (Date, DateTime) states the rule for missing components only. It does not say whether an invalid component gives an error or null, so null would also be a defensible choice. A value that is not a date, and that later turns into NaN, is not.
The selectors can be fed from computed components (for example Date(year from X, month from X, 28 + n)), so this is not limited to literals.
Cause: the ELM Date and DateTime expressions pass the evaluated components to the datatype constructors without validation:
(DateTime at L8-L48). A possible fix is to validate the components there (or in DT.Date/DT.DateTime), for example with luxon's DateTime.fromObject(...).isValid (the string parser already relies on luxon's isValid in isValidDateStringFormat).
Environment:
- cql-execution 3.3.2 and 4.0.0-beta.1 (same results);
- ELM from
@cqframework/cql5.8.0 (npm); - Node 24, Windows 11, TZ=UTC.
Found while differential testing date operators across engines. Related: #413 (out-of-range results of date arithmetic).
- 主要言語
- JavaScript
- スター
- 86
- フォーク
- 40
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cqframework/cql-execution のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cqframework/cql-execution#410 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cqframework/cql-execution#407 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cqframework/cql-execution#406 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
cqframework/cql-execution#413 ·
-
Length throws TypeError when its null operand is not an As expression (e.g. an expression reference)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
cqframework/cql-execution#412 ·
cqframework/cql-execution の issue をすべて見る
似ている issue
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
ManageIQ/manageiq-ui-service#2259 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
electerious/Ackee#411 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
babalae/bettergi-scripts-list#3905 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
dedicatedcode/reitti#1445 ·
メンテナーはふだん 1 日以内に返信