Skip to content

fix(admin): Instagram accounts enrichment API 프로덕션 500 오류 #578

@CIOI

Description

@CIOI

요약

프로덕션 admin /admin/data-pipeline/instagram-accountsHTTP 500 + 빈 body 로 실패합니다.

근본 원인(확정): BFF(packages/web/.../instagram-accounts/route.ts)가 createAdminSupabaseClient()operation DB service role 을 요구하는데, Vercel web에는 DATABASE_SERVICE_ROLE_KEY를 두지 않는 것이 맞음(보안). prod에서 키가 없어 uncaught throw → Next가 빈 500 반환.

로컬은 .env.local에 service role이 있어 재현되지 않음.

보안 / 아키텍처

  • service role은 web(Vercel)이 아니라 api-server / ai-server에만 있어야 함.
  • Vercel prod에 service role을 추가하는 것은 증상 응급처치일 뿐, 정책 위반.
  • data-pipeline의 settings PATCH는 이미 api-server 프록시 패턴 사용 중 → 목록 GET도 동일하게 이관.

수정 방향 (본 이슈 스코프)

  1. api-server GET /api/v1/admin/entity-enrichment/instagram-accounts
    • operation DB 직접 조회 (SeaORM/SQL, state.db)
    • admin_db_middleware + JWT
    • accounts + pagination + summary (DB-side count, metadata 전량 fetch 금지)
  2. web BFF → api-server 프록시만 (service role 제거)
    • settings / usage는 기존처럼 api-server 다른 엔드포인트 프록시 유지
  3. web에 try/catch + JSON 에러 (프록시 실패 시 빈 500 방지)

재현

로컬 (prod DB 불필요):

  1. main checkout
  2. packages/web/.env.local에서 DATABASE_SERVICE_ROLE_KEY 제거
  3. /admin/data-pipeline/instagram-accounts → 500 빈 body

완료 조건

  • web(Vercel)에 DATABASE_SERVICE_ROLE_KEY 추가 없이 prod admin 페이지 동작
  • GET /api/v1/admin/entity-enrichment/instagram-accounts (api-server) → 200
  • web BFF GET /api/admin/data-pipeline/instagram-accounts → 200 + JSON
  • 실패 시 JSON { error } (empty body 없음)
  • summary count가 operation DB와 일치

관련

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions