Skip to content

fix(validation): repair broken run_validation call signatures#372

Open
blakenan-bellese wants to merge 1 commit into
mainfrom
fix/validation-run-signature-drift
Open

fix(validation): repair broken run_validation call signatures#372
blakenan-bellese wants to merge 1 commit into
mainfrom
fix/validation-run-signature-drift

Conversation

@blakenan-bellese

Copy link
Copy Markdown
Collaborator

Summary

  • The validation-run path (run_validation in backend/app/services/validation.py) had drifted out of sync with two refactors in fhir_client.py, so every validation run crashed — it never produced results.
  • Fix 1: wipe_patient_data() gained a required keyword-only base_url arg; the call site omitted it → run failed instantly with missing 1 required keyword-only argument: 'base_url'.
  • Fix 2: gather_patient_data() now returns a GatherResult dataclass; the code used it as a plain resource list → every patient errored with 'GatherResult' object is not iterable.

Both fixes mirror the correct usage already present in orchestrator.py (base_url=settings.MEASURE_ENGINE_URL, and gather_result.resources).

Related issue

Type of change

  • Bug fix

Root cause / why it wasn't caught

TestRunValidation mocked the old contracts — gather_patient_data returning a list, and only asserting wipe_patient_data was "called once". So the unit tests passed against code that could never work at runtime. This PR updates the mocks to return GatherResult and strengthens the wipe assertion to require base_url=MEASURE_ENGINE_URL, so the regression cannot recur silently.

Checklist

  • Tests added or updated (updated TestRunValidation mocks + wipe regression guard)
  • docs/ updated (no architecture/API change)
  • No new ADRs needed
  • Security implications considered (N/A — internal call-signature fix)

Test plan

Run locally (all green):

  • Lint: cd backend && ruff check app/ tests/ && ruff format --check app/ tests/ → clean
  • Unit: cd backend && python3 -m pytest tests/ --ignore=tests/integration503 passed
  • CI-equivalent integration: USE_PREBAKED=1 ./scripts/run-integration-tests.sh --ignore=... (the six PR-check ignores) → 29 passed, 7 skipped

End-to-end: uploaded CMS1028FHIRPCSevereOBComps (141 test patients) via /validation/upload-bundle, then POST /validation/run — previously crashed before any results; now completes and returns per-patient pass/fail/error (43 pass / 2 fail / 96 eval-error). The remaining eval errors are a separate measure-evaluation issue, not part of this fix.

🤖 Generated with Claude Code

The validation-run path (run_validation) drifted out of sync with two
refactors in fhir_client.py and crashed every run:

1. wipe_patient_data() gained a required keyword-only `base_url` argument
   but the call site omitted it → every run failed instantly with
   "missing 1 required keyword-only argument: 'base_url'".
2. gather_patient_data() now returns a GatherResult dataclass, but the
   code used the return value as a plain resource list → every patient
   errored with "'GatherResult' object is not iterable".

Fixes mirror the correct usage already present in orchestrator.py:
- wipe_patient_data(base_url=settings.MEASURE_ENGINE_URL, strict=False)
- resources = gather_result.resources

The drift went undetected because TestRunValidation mocked the OLD
contracts (gather returning a list, wipe asserted only "called once").
Updated the mocks to return GatherResult and strengthened the wipe
assertion to require base_url=MEASURE_ENGINE_URL, so this regression
cannot recur silently.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant