Skip to content

fix(api): BUG-092 — clinician 대시보드 org-scope 시드 정합 + 응답 EmailStr 500 수정 - #99

Merged
dhkim-kr merged 1 commit into
Masterfrom
fix/bug092-clinician-org-visibility
Jul 27, 2026
Merged

dhkim-kr merged 1 commit into
Masterfrom
fix/bug092-clinician-org-visibility

Conversation

@dhkim-kr

Copy link
Copy Markdown
Member

배경

  • BUG-092 / ADR-049: org-scope 필터(ISS-022, PR [critical][platform][security] Clinician dashboard has no org/patient authorization — any clinician reads all patients (PHI/IDOR) #22 — clinician은 PatientProfile.target_hospital_id == organization_id인 환자만 조회) 도입 후, 시드 환자가 전원 target_hospital_id=NULL이라 대시보드가 구조적으로 비어 있던 결함의 후속 수정 세트.
  • 라이브 발병(2026-07-27, DGX): 기존 NULL 환자들에 org가 backfill되어 가시화되는 순간, vp-*@sim.local·*@example.com 등 special-use 도메인 이메일이 응답 스키마의 EmailStr 재검증에 걸려 GET /api/v1/clinician/patients 전체가 500 (pydantic ValidationError, services/clinician.py:124). 웹 대시보드는 '환자 목록을 불러오지 못했어요 (코드: INTERNAL_ERROR)' 상태.

파일별 변경

파일 변경 설명
apps/api/src/schemas/clinician.py EmailStrstr (PatientListItem·PatientDetail) DB에 이미 저장된 User.email을 echo하는 응답측 재검증 제거. 입력 검증(register)은 EmailStr 유지 — 보안 통제 변경 없음. 근거 주석 포함
apps/api/scripts/seed_demo.py _make_personaorg_id 전달, target_hospital_id 배선 시드 환자를 데모 clinician의 org에 배정 — org-scope 하에서 시드가 비가시였던 원결함 수정
apps/api/scripts/backfill_bug092_target_hospital.py 신규 기존 NULL 행 backfill 운영 도구(idempotent). 참고: DGX에는 이미 별도 경로로 backfill 적용됨 — 타 환경/재현용
apps/api/src/services/clinician.py 모듈 docstring만 Phase 1a '전 환자 공개' 서술을 org-scope 현행으로 정정. 로직 무변경
apps/api/tests/repro/test_bug_092_org_scope_seed_mismatch.py 신규 repro 3건: 시드-org 정합, demo-형 환자 detail/session 도달성

검증

  • repro 테스트: 로컬 PG 대상 DATABASE_URL=<socket DSN> uv run pytest tests/repro/test_bug_092_org_scope_seed_mismatch.py3/3 passed (PG 미가용 시 skip 설계)
  • 로컬 라이브: 이 수정이 적용된 트리로 서빙 중인 로컬 스택(:8000/:3000)에서 clinician 로그인→환자 6명 목록·상세 렌더 정상
  • DGX 재현: Master(수정 미포함) 컨테이너에서 상기 500 트레이스백 실확인 — 본 수정의 EmailStr 제거가 직접 해소

머지 후 필요한 후속 (다음 작업자)

  1. DGX api 재배포 — 이 수정은 코드만이므로: cd ~/AI_Champion/neurosync && git pull && docker compose -f infra/deploy/docker-compose.dgx.yml build api && docker compose -f infra/deploy/docker-compose.dgx.yml up -d api → 대시보드 500 해소 확인
  2. (선택) 시뮬레이션/프로브 계정(vp-*@sim.local, probe.*, *smoke*)이 의료진 대시보드에 노출됨 — 실환자만 보이게 할지 org 해제/필터링은 product 결정 대기

Refs: BUG-092(error.md), ADR-049·ADR-051(discussion.md)

…l 스크립트 (ADR-049)

- schemas/clinician.py: PatientListItem/PatientDetail email을 EmailStr->str.
  DB에 이미 저장된 email을 echo하는 응답측 재검증이 RFC 밖 주소(@demo,
  *.local, example.com 등 special-use 도메인)에서 목록/상세 전체 500을
  유발 — DGX 라이브 발병 확인(2026-07-27).
- scripts/seed_demo.py: 데모 환자를 clinician org로 배선. org-scope 필터
  (ISS-022/PR #22) 하에서 NULL target_hospital_id 시드는 구조적 비가시.
- scripts/backfill_bug092_target_hospital.py: 기존 NULL 행 backfill 도구
  (idempotent, dry-run 지원).
- services/clinician.py: 모듈 docstring을 org-scope 현행으로 정정(로직 무변경).
- tests/repro/test_bug_092_org_scope_seed_mismatch.py: repro 3건
  (로컬 PG 대상 3/3 passed).
@dhkim-kr
dhkim-kr force-pushed the fix/bug092-clinician-org-visibility branch from 2edddec to 759360c Compare July 27, 2026 06:30
@dhkim-kr
dhkim-kr merged commit cdb3435 into Master Jul 27, 2026
2 checks passed
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