`Message` with severity `'Error'` does not stop evaluation
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
調査の方向性
Start with src/elm/message.ts and the TestMessageError case in tests/cql/CqlErrorsAndMessagingOperatorsTest.xml; compare the current listener behavior with the specification quoted in the issue. Check both true and false conditions, Error and Warning severities, and a Message value used by a later expression. Done means the error case fails evaluation as expected while the other cases continue to return their source values.
索引モデルが issue の本文から書いたものです。
説明
Summary
When the condition of Message is true and the severity is 'Error', the specification says evaluation stops with a run-time error. cql-execution calls the message listener (if any) and returns the source value instead, so evaluation continues (src/elm/message.ts).
Reproduction
library MessageSemantics version '1.0.0'
define ErrorTrue: Message(1, true, 'c', 'Error', 'boom')
define ErrorUsedLater: Message(1, true, 'c', 'Error', 'boom') + 1
define WarningTrue: Message(1, true, 'c', 'Warning', 'w')
define ErrorFalse: Message(1, false, 'c', 'Error', 'boom')
| Expression | Expected | cql-execution 3.3.2 | cql-execution 4.0.0-beta.1 |
|---|---|---|---|
ErrorTrue |
run-time error | 1 | 1 |
ErrorUsedLater |
run-time error | 2 | 2 |
WarningTrue |
1 | 1 | 1 |
ErrorFalse |
1 | 1 | 1 |
The JavaScript build of the reference engine (@cqframework/cql 5.8.0) raises an error for the first two expressions.
Specification
CQL Reference, Message: "Error – The operation produces a run-time error and return the message to the calling environment. This is the only severity that stops evaluation. All other severities continue evaluation of the expression."
The official test TestMessageError in cql-tests (tests/cql/CqlErrorsAndMessagingOperatorsTest.xml, invalid="true") expects this error; cql-execution fails it.
Effect on published libraries
Several published libraries end a case with Message(<placeholder>, true, ..., 'Error', ...) for inputs they cannot handle, relying on evaluation to stop. With cql-execution the placeholder is returned and evaluation continues. Two examples (FHIR R4 data through cql-exec-fhir 2.2.0, cql-execution 3.3.2 and 4.0.0-beta.1 give the same results):
- WHO SMART HIV (
smart.who.int.hiv),HIVCommon.GetDurationInDays(value FHIR.Duration): theelsebranch isMessage(1000, true, 'Undefined', 'Error', 'Unsupported duration unit ' + value.code.value). For aMedicationRequestauthored on 2026-01-10 whosedispenseRequest.expectedSupplyDurationis{ "value": 30, "unit": "days" }(nocode) or has"code": "day", the function returns1000andHIVCommon."Prescription Relevant Period"evaluates toInterval[@2026-01-10, @2028-10-06]instead of raising an error (with"code": "d"it isInterval[@2026-01-10, @2026-02-09]). - CDC Opioid CDS (
fhir.cdc.opioid-cds-r4),OpioidCDSCommon.GetDurationInDays: same pattern. The placeholder becomes1000 '1', soOpioidCDSRoutines."Is Acute Pain Prescription?"and"Is Subacute or Chronic Pain Using Expected Supply Duration"both evaluate tonullfor such a prescription.
Guards of the form Message(null as T, true, ..., 'Error', ...) (for example for a string alternative of a choice-typed element) likewise return null, and the calling logic continues as if the input were merely missing.
Documented behaviour and a workaround
OVERVIEW.md (MessageListener) says that ConsoleMessageListener logs Error messages to stderr, so continuing may be intended. A listener that throws from onMessage when severity === 'Error' gives the specified behaviour: with 3.3.2 and 4.0.0-beta.1, ErrorTrue and ErrorUsedLater then raise an error and WarningTrue/ErrorFalse still return 1. If continuing is the intended default, documenting that 'Error' does not halt evaluation, and how to opt in to halting, would help library authors and integrators.
Suggested fix
After notifying the listener, throw an error carrying the code and message when the condition is true and the severity is 'Error'. The specification does not say whether the severity comparison is case-sensitive; the reference engine treats 'error' as 'Error'.
Environment
The same code is on master at e87e3fa (src/elm/message.ts).
cql-execution 3.3.2 and 4.0.0-beta.1, Node 24, Windows 11, TZ=UTC, translator @cqframework/cql 5.8.0.
- 主要言語
- 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 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
cqframework/cql-execution#416 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cqframework/cql-execution#414 ·
cqframework/cql-execution の issue をすべて見る
似ている issue
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount due対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
verified whatsapp
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 6 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信