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.rb100-102 부근 (rescue 절 사이에 3줄 삽입)
tesla: spec/models/quote_spec.rb#
- What:
apply!가Cupix::Errors::Billing을 raise 하는 경로(예: BILL10000 스케줄 중복, invalid billing_account 등)에 대해Cupix::Logger가warn으로 호출되고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.rb에Cupix::Errors::Billing을 raise 하는 경로에 대한expect(Cupix::Logger).to have_received(:warn)검증이 존재한다. -
ruby -c app/models/quote.rb및ruby -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_receivedassertion).