NoMethodError: undefined method `to_i' for an instance of ActionController::Parameters
Summary: NoMethodError: undefined method `to_i' for an instance of ActionController::Parameters
결과#
사용자가 선택한 단기 개선(1주 이내) track 의 저비용 대안을 구현했다. ClientErrorController 에 ActionController::Parameters 메시지에 한정한 narrow rescue_from NoMethodError 를 추가해, malformed client input 으로 인한 예외를 500 대신 400(ARG10000)으로 매핑한다. 그 외 NoMethodError(진짜 nil 참조 버그)는 재-raise 하여 500 으로 계속 드러난다. blind validator APPROVED.
Pull Requests#
| Repo | PR | Branch |
|---|---|---|
| tesla | https://dev.azure.com/cupix/tesla/_git/tesla/pullrequest/89595 | feature/TSLA-13890 |
변경 내용#
app/controllers/concerns/client_error_controller.rb:rescue_from NoMethodError, with: :invalid_parameter_type_400_error추가 + handler 신규 정의. handler 는exception.message가ActionController::Parameters를 포함할 때만Cupix::Errors::Parameter(ARG10000, 400) 로 매핑하고, 아닐 경우raise exception으로 재-raise.spec/controllers/concerns/client_error_controller_spec.rb:invalid_parameter_type_400_errordescribe 블록 2 케이스 추가 (match→400, non-match→re-raise).
Scope Notes#
- 선택된 track 의 다른 방안(공통 스칼라 강제 헬퍼로 산재한
params[...].to_i12+개 일괄 치환)과 즉시 조치·장기 개선(스키마 계약 도입) 섹션은 요청 범위 밖이라 구현하지 않았다. - 배포 후 재발/미분류 500 추이 모니터링:
service:cupixworks-api "ActionController::Parameters".
Validation#
- Verdict: APPROVED (attempt 1). 상세:
validation.mdx. - 로컬 검증:
ruby -c문법 통과, rubocop(changed files) no offenses, pre-commit rubocop hook + pre-push rspec hook 모두 Passed.
Cleanup#
Worktree 는 검토를 위해 보존됨. 리뷰/머지 후 제거:
bash
cd $REPOS_DIR/tesla
git worktree remove /home/ec2-user/error-sweeper/.worktrees/a21860c9-bf2b-4601-8047-ad862280f91b/tesla