Skip to content

CodeSystem/$validate-code & ValueSet/$expand: HTTP 500 "TerminologyError is not a constructor" when a ValueSet depends on an unknown supplement #241

@jmandel

Description

@jmandel

Summary

When a value set's compose.include carries a valueset-supplement extension (valueString/valueUri) naming a supplement the server does not have, $expand/$validate-code crash with HTTP 500 and a JavaScript TypeError instead of returning a structured error about the unknown supplement.

Repro (live)

curl -sS -X POST 'https://tx.fhir.org/r4/ValueSet/$expand' \
  -H 'Content-Type: application/fhir+json' -w '\nHTTP %{http_code}\n' -d '{
  "resourceType":"Parameters","parameter":[{"name":"valueSet","resource":{
    "resourceType":"ValueSet","status":"active","compose":{"include":[{
      "system":"http://hl7.org/fhir/administrative-gender",
      "extension":[{"url":"http://hl7.org/fhir/StructureDefinition/valueset-supplement",
                    "valueUri":"http://example.org/no-such-supplement"}]}]}}}]}'

Observed

HTTP 500
{"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"exception","details":{"text":"TerminologyError is not a constructor"},"diagnostics":"TerminologyError is not a constructor"}]}

Likely cause

tx/workers/worker.js:1 does const { TerminologyError } = require('../operation-context'), but operation-context.js does not export TerminologyError (it is exported from tx/library/errors.js). So at worker.js:321 — the checkSupplements "ValueSet depends on supplement '…' that is not known" path — TerminologyError is undefined and new TerminologyError(...) throws is not a constructor, masking the intended clean error. (Controls: with no supplement extension → 200; with the value as valueCanonical instead of valueUri/valueString → 200, because worker.js:319 only reads valueString||valueUri.)

Expected

A structured OperationOutcome reporting the unknown supplement (the intent of the throw), not an uncaught TypeError. (Per http.html, a failure "SHOULD be accompanied by an OperationOutcome"; per operationoutcome.html the issue should state the real reason.) Related: #104 (unknown useSupplement handling).


Confirmed live against https://tx.fhir.org on 2026-06-06 (software FHIRsmith 0.9.6). Source line refs are from the published main branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions