Symptom
Pressing the sample-data loader against a server that already holds (some of) the sample resources fails partway through:
5/8 bundles loaded — Server returned HTTP 500: {"issue":[{"code":"exception","diagnostics":"batch insert into resources: ERROR: duplicate key value violates unique constraint \"resources_pkey\" (SQLSTATE 23505)"}]}
Root cause
The sample bundles' transaction entries use POST but each entry.resource carries an id. Per the FHIR create interaction the server ignores client-supplied ids, but wso2/fhir-server honors them (createInTx keeps body["id"]), so a second load reuses the same ids and hits the resources primary key.
The embedded ids are inert otherwise: inter-entry references all use urn:uuid fullUrls, contained (#) references, or conditional (identifier=) references — none use Type/id form (verified across the bundles).
Fix sketch (client-side)
Strip resource.id from POST entries in loadSampleData before submitting. Implemented and verified on branch prdai-archive:fix/sample-loader-idempotent (same bundle POSTs twice with 200s against the compose FHIR server; 104/104 tests) — see closed #26 for the diff. A PR will follow.
An alternative/complementary server-side fix (make bundle POST entries always mint server ids per spec) belongs in wso2/fhir-server.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PQQK8BwmSJzs2qqbmHqNuV
Symptom
Pressing the sample-data loader against a server that already holds (some of) the sample resources fails partway through:
Root cause
The sample bundles' transaction entries use
POSTbut eachentry.resourcecarries anid. Per the FHIR create interaction the server ignores client-supplied ids, but wso2/fhir-server honors them (createInTxkeepsbody["id"]), so a second load reuses the same ids and hits theresourcesprimary key.The embedded ids are inert otherwise: inter-entry references all use
urn:uuidfullUrls, contained (#) references, or conditional (identifier=) references — none useType/idform (verified across the bundles).Fix sketch (client-side)
Strip
resource.idfrom POST entries inloadSampleDatabefore submitting. Implemented and verified on branchprdai-archive:fix/sample-loader-idempotent(same bundle POSTs twice with 200s against the compose FHIR server; 104/104 tests) — see closed #26 for the diff. A PR will follow.An alternative/complementary server-side fix (make bundle POST entries always mint server ids per spec) belongs in wso2/fhir-server.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PQQK8BwmSJzs2qqbmHqNuV