ES /docs

Quote#schedule_apply! logs validation errors as ERROR — missing exception filtering

Fix Plan: [Quote] Quote application failed: Billable already has a scheduled quote

Changes#

tesla: app/models/quote.rb#

  • What: Quote#apply!rescue Cupix::Errors::Parameter 절 뒤, rescue StandardError 절 앞에 rescue Cupix::Errors::Billing => e 를 추가하고 Cupix::Logger.warn("[Quote][#{number}] Quote application failed: #{e.message}") 로 로깅한 뒤 raise e 로 재던짐. 기존 rescue StandardError 는 그대로 유지하여 무결성/시스템 오류는 계속 error 레벨로 로깅.
  • Why: Cupix::Errors::Billing(특히 BILL10000 계열: 스케줄된 quote 중복, 잘못된 상태, invalid billing_account 등)은 back-office 담당자의 입력 검증성 예외이며 HTTP 400 을 반환하는 정상 방어 로직이다. RCA 상 서비스 사용자 영향은 없고, 재시도가 반복될 때 error 레벨 로그가 대시보드/알림을 오염시킨다. Memory 상 동일 패턴(예상 운영 시나리오는 warn) 이 다수 확인됨(27e43020, 6366fb77, 2c20f518, d1240f1d, cc2e2887).
  • Lines: app/models/quote.rb 100-102 부근 (rescue 절 사이에 3줄 삽입)

tesla: spec/models/quote_spec.rb#

  • What: apply!Cupix::Errors::Billing 을 raise 하는 경로(예: BILL10000 스케줄 중복, invalid billing_account 등)에 대해 Cupix::Loggerwarn 으로 호출되고 error 로는 호출되지 않는지를 검증하는 example 을 추가. 기존 Cupix::Errors::Parameter / StandardError 경로가 여전히 error 로 로깅되는지도 회귀 방지 example 로 유지.
  • Why: 팀 컨벤션 상 rescue 를 좁힐 때 spec 을 함께 갱신해야 한다(memory: 2c20f518). Spec 이 정확한 예외 클래스를 raise 하지 않으면 좁혀진 rescue 를 놓치고 silent 통과할 수 있음.
  • Lines: 기존 describe '#apply!' 블록에 추가 (신규 context "when billable already has a scheduled quote").

Acceptance Criteria#

  • git diff app/models/quote.rb 결과가 rescue Cupix::Errors::Billing 을 새로 추가하고 Cupix::Logger.warn 을 사용함을 보여준다.
  • git diff app/models/quote.rb 상 기존 rescue StandardError => e 블록과 Cupix::Logger.error("[Quote][#{number}] Quote application failed: ...") 로그가 그대로 유지된다(무결성/시스템 오류 회귀 방지).
  • grep -n 'rescue Cupix::Errors::Billing' app/models/quote.rb 결과가 1건 이상.
  • spec/models/quote_spec.rbCupix::Errors::Billing 을 raise 하는 경로에 대한 expect(Cupix::Logger).to have_received(:warn) 검증이 존재한다.
  • ruby -c app/models/quote.rbruby -c spec/models/quote_spec.rb 구문 오류 없음.

Tests#

  • 기존 테스트: spec/models/quote_spec.rb, spec/lib/cupix/cron/scheduled_quote_spec.rb — TSLA-12975 에서 추가된 schedule_apply! 경로 커버.
  • 신규 테스트: spec/models/quote_spec.rb 에 "logs at warn when Cupix::Errors::Billing is raised" 성격의 example 추가 (Cupix::Logger.warn/error stub + have_received assertion).