`-BundleToResources` silently loses resources (duplicate ids, id-less entries, unparseable bundles), then `-db=true` deletes the source

Aperta
#602 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend, tooling

Direzione di ricerca

Start with tooling/src/main/java/org/opencds/cqf/tooling/operation/BundleToResources.java and trace bundle discovery, resource naming and writing, extraction counts, and the -db=true deletion path. Reproduce the reported cases with the sample command and inspect the output and exit status. Done means duplicate and id-less entries cannot be silently overwritten, parse failures are reported, counts reflect written and skipped resources, and source bundles are deleted only after successful extraction.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

-BundleToResources (tooling/src/main/java/org/opencds/cqf/tooling/operation/BundleToResources.java, unchanged
on master e50dc913) can lose resources without any error, report a count that includes them, and then, with
-db=true, delete the only copy. The IG template's _extractBundleResources.sh runs it with -db=true, so this
affects the standard test-case workflow in content IGs.

Reproduced with tooling-cli-3.9.1.jar, the version the template scripts pin.

  1. Resources with the same resourceType/id overwrite each other. The output file name is
    <resourceType>-<idPart>.json, written with a plain FileOutputStream, so the last entry wins. The extraction
    count still counts every entry. A bundle with two Encounter/e1 entries reports "4 resources extracted" and
    writes 3 files; only the second Encounter survives. Output tasks run in parallel, so collisions across bundles
    in the same output folder are also last-writer-wins, in no defined order.
  2. Entries without an id are named from the entry and overwrite each other. An entry with a urn:uuid
    fullUrl and no id is written as null-urn:uuid:<uuid>.json. That's not a valid file name on Windows. With no
    fullUrl, every id-less entry is written to null-null.json. In a bundle with an id-less Observation and an
    id-less Condition, only the Condition survives.
  3. Files that fail to parse are skipped silently. discoverBundlesRecursively catches every exception and
    returns null. A bundle with an invalid value (for example "birthDate": "not-a-date") is never counted or
    reported. The run ends "Process complete." with no mention of it.
  4. -db=true deletes the source bundle regardless of 1–3. After a lossy extraction, the bundle, which is the
    only copy of the lost resources, is deleted.

Steps to reproduce:

mkdir -p t/c
echo '{"resourceType":"Bundle","type":"collection","entry":[
 {"fullUrl":"urn:uuid:a","resource":{"resourceType":"Patient","id":"p1"}},
 {"fullUrl":"urn:uuid:b","resource":{"resourceType":"Encounter","id":"e1","status":"finished","class":{"code":"AMB"}}},
 {"fullUrl":"urn:uuid:c","resource":{"resourceType":"Encounter","id":"e1","status":"finished","class":{"code":"IMP"}}},
 {"fullUrl":"urn:uuid:d","resource":{"resourceType":"Observation","status":"final","code":{"text":"x"}}}]}' > t/c/bundle.json
java -jar tooling-cli-3.9.1.jar -BundleToResources -p=t -v=r4 -op=t -db=true
# "4 resources extracted"; files: Encounter-e1.json (IMP only), Patient-p1.json, null-urn:uuid:d.json; bundle.json deleted

Expected behaviour:

  • Fail the bundle, with a clear message, when two entries share a resourceType/id. Name the bundle and the id.
    Never overwrite silently.
  • Fail an entry with no id, or offer an explicit option to assign one. Never write null-* files.
  • Report every file that couldn't be parsed, with the parser's message, and end with a non-zero exit code.
  • Make the count report what was written and what was skipped.
  • With -db=true, delete a bundle only when all of its entries were written.

🤖 Generated with Claude Code

Lingua principale
Java
Stelle
22
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cqframework/cqf-tooling

Tutte le issue di cqframework/cqf-tooling

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.