Feat(#21): RabbitMQ 기반 스미싱 분석 요청 Consumer 구현 - #25
Conversation
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds a RabbitMQ-backed analysis request consumer with strict event schemas, durable topology setup, retry handling, pipeline integration, configurable FastAPI startup/shutdown management, Compose settings, dependency updates, and comprehensive tests. ChangesRabbitMQ analysis processing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RabbitMQ
participant AnalysisRequestConsumer
participant AnalysisRequestHandler
participant SmishingAnalysisService
RabbitMQ->>AnalysisRequestConsumer: Deliver analysis request
AnalysisRequestConsumer->>AnalysisRequestHandler: Handle validated event
AnalysisRequestHandler->>SmishingAnalysisService: Analyze message content
SmishingAnalysisService-->>AnalysisRequestHandler: Return analysis result
AnalysisRequestHandler-->>AnalysisRequestConsumer: Report success or failure
AnalysisRequestConsumer->>RabbitMQ: Acknowledge, retry, or reject
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 3
🧹 Nitpick comments (1)
app/infrastructure/rabbitmq/schemas.py (1)
18-26: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winConsider bounding
contentlength.
senderandclientMessageIdare capped, butcontentis unbounded and flows directly into the analysis pipeline (likely an LLM call). A malformed or oversized message could trigger expensive or failing downstream calls.♻️ Proposed bound
- content: str + content: str = Field(max_length=5000)🤖 Prompt for 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. In `@app/infrastructure/rabbitmq/schemas.py` around lines 18 - 26, Update the AnalysisRequestedPayload.content field to enforce an explicit maximum length using Pydantic Field, matching the bounded validation style already used for sender and clientMessageId. Choose the appropriate limit for analysis input and preserve content’s required-string behavior.
🤖 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/infrastructure/rabbitmq/consumer.py`:
- Around line 108-140: The _handle_processing_failure method incorrectly treats
message.redelivered as proof that this handler already retried the message.
Replace that check with application-level retry-attempt state, increment or
record the attempt when requeueing, and reject only after the configured single
retry has actually been attempted; preserve the existing logging and nack/reject
outcomes.
In `@app/main.py`:
- Around line 57-60: Update the shutdown flow around consumer.stop() so
rabbitmq.close() executes in a finally block even when consumer shutdown raises.
Keep the consumer None check and ensure the RabbitMQ connection is always
closed.
In `@docker-compose.yml`:
- Around line 12-18: Add a fallback default to the RABBITMQ_URL environment
entry in the Compose configuration, using the same local RabbitMQ URL expected
by config.py when RABBITMQ_DOCKER_URL is unset. Preserve the existing override
behavior when RABBITMQ_DOCKER_URL is provided.
---
Nitpick comments:
In `@app/infrastructure/rabbitmq/schemas.py`:
- Around line 18-26: Update the AnalysisRequestedPayload.content field to
enforce an explicit maximum length using Pydantic Field, matching the bounded
validation style already used for sender and clientMessageId. Choose the
appropriate limit for analysis input and preserve content’s required-string
behavior.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ae0d14fa-84b3-4229-a26f-e8394fa962b1
📒 Files selected for processing (16)
app/core/config.pyapp/infrastructure/rabbitmq/__init__.pyapp/infrastructure/rabbitmq/connection.pyapp/infrastructure/rabbitmq/consumer.pyapp/infrastructure/rabbitmq/handler.pyapp/infrastructure/rabbitmq/schemas.pyapp/main.pydocker-compose.ymlrequirements.txttests/analysis/test_router.pytests/infrastructure/rabbitmq/__init__.pytests/infrastructure/rabbitmq/test_connection.pytests/infrastructure/rabbitmq/test_consumer.pytests/infrastructure/rabbitmq/test_handler.pytests/infrastructure/rabbitmq/test_lifecycle.pytests/infrastructure/rabbitmq/test_schemas.py
📝 개요
Spring에서 RabbitMQ로 발행한 문자 분석 요청을 FastAPI가 소비하고, 기존 스미싱 분석 파이프라인으로 전달하도록 구현했습니다.
🔗 관련 이슈
🎯 주요 변경 사항
✅ PR 체크리스트
uvicorn구동 또는 테스트 코드)를 통과했습니다.Summary by CodeRabbit