Skip to content

Posting a non-R5 Bundle to /r4 or /r3 returns HTTP 500 with an HTML stack trace (bundleToR5 always throws) #243

@jmandel

Description

@jmandel

Summary

POSTing any Bundle to a non-R5 endpoint (/r4, /r3, /r4b) returns HTTP 500 with a raw HTML stack-trace page (not an OperationOutcome). The R4/R3→R5 Bundle converter throws unconditionally.

Repro (live)

curl -sS -X POST 'https://tx.fhir.org/r4/' \
  -H 'Content-Type: application/fhir+json' -w '\nHTTP %{http_code} | %{content_type}\n' \
  -d '{"resourceType":"Bundle","type":"batch","entry":[]}'
# => HTTP 500, text/html, <!DOCTYPE html> … stack trace through tx/tx.js:393

Likely cause

tx/xversion/xv-bundle.js bundleToR5(): after the R5 early-return it loops the entries and then runs an unconditional throw new Error('Unsupported FHIR version: …') (so the line is reached for every non-R5 Bundle; it should be return jsonObj, mirroring the R5 early-return and bundleFromR5). It is invoked from the inbound body-conversion middleware (tx/tx.js ~:469, convertResourceToR5(req.body, …)) before routing and with no try/catch, so any Bundle body on a non-R5 endpoint 500s regardless of the target operation.

Expected

The Bundle should be processed (or rejected with a clean 4xx OperationOutcome) — not an uncaught throw rendered as an HTML 500. (Per http.html, errors at a FHIR-aware level SHOULD be an OperationOutcome; cf. #100 for the HTML-instead-of-OperationOutcome theme.)


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