fix: OpenAI 분석 응답 스키마 실패 재시도 - #45
Conversation
|
Warning Review limit reached
More reviews will be available in 43 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughOpenAI 분석 응답의 간헐적 스키마 검증 실패 문제를 해결하기 위해 프롬프트 제약을 강화하고 어댑터에 재시도 로직을 추가하며, 이를 검증하는 테스트를 도입했습니다. ChangesOpenAI 응답 스키마 검증 재시도
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/services/openai_adapter.py`:
- Around line 53-58: The current logger.warning call in openai_adapter.py logs
the full ValidationError string (logger.warning(..., exc)), which may include
sensitive input_value content; instead, catch the ValidationError and log a
sanitized summary: extract only the error paths/types/counts (e.g., from
ValidationError.errors() or similar) and log a concise message like
"[OpenAIAdapter] 응답 스키마 검증 실패. attempt=%s/%s, errors=%s" with a list of error
locations/types or a count, omitting any input_value or raw text; update the
logger.warning invocation (and any surrounding except block that handles
ValidationError) to build and log this sanitized summary rather than the full
exc.__str__().
- Around line 86-94: The retry prompt currently appends the full ValidationError
string which can include huge input_value data; update
_build_schema_retry_message to instead extract exc.errors(), map each error to a
concise dict with only loc, msg, and type, serialize that list (e.g., join or
JSON) and truncate the serialized string to a safe max length (choose a constant
like 500-1000 chars) before including it in the returned message; ensure you
reference ValidationError and exc.errors() and apply the truncation so the retry
prompt stays short and focused.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e07e5ece-913d-4faa-9162-e86f237d4588
📒 Files selected for processing (3)
app/services/newsletter_prompt.pyapp/services/openai_adapter.pytests/test_openai_adapter.py
📌 작업 요약
NewsletterAnalysisResponse스키마 검증에 실패하는 경우 1회 자동 재시도하도록 개선items/checklistItems배열 원소는 반드시 JSON object여야 한다는 보정 지시 추가items.1 = "},{"형태의 스키마 이탈 응답에 대한 재시도 성공/최종 실패 테스트 추가🌿 브랜치 정보
bugfix/#44-openai-schema-retrydevelop(기본)✅ 체크리스트
feat/refac/hotfix/chore/design/bugfix)feat/fix/refactor/docs/style/chore)🧪 테스트 결과
Summary by CodeRabbit
릴리스 노트
Bug Fixes
Tests