-
Notifications
You must be signed in to change notification settings - Fork 58
LCORE-464: fix potential None reference handling #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCORE-464: fix potential None reference handling #418
Conversation
|
Warning Rate limit exceeded@tisnik has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 3 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds defensive checks in retrieve_response to avoid accessing a missing response.output_message.content: returns (conversation_id, content) when present; otherwise logs a warning and returns (conversation_id, "") as a fallback. Function signature now includes a return type annotation and expanded pylint suppression. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant retrieve_response
participant Logger
Caller->>retrieve_response: call with client, model_id, query_request, token, mcp_headers
alt response.output_message and content present
retrieve_response-->>Caller: (conversation_id, output_message.content)
else missing output_message or content
retrieve_response->>Logger: warn("output_message or content missing")
retrieve_response-->>Caller: (conversation_id, "")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/app/endpoints/query.py (1)
495-499: Remove type ignores and make content extraction more robustAvoid the type: ignore by using getattr and handle non-str content safely. Also enrich the warning with conversation_id for easier triage.
Apply this diff:
- if response is not None and response.output_message is not None: # type: ignore[union-attr] - return str(response.output_message.content), conversation_id # type: ignore[union-attr] - - logger.warning("Response does not contain any message to be returned") - return "", conversation_id # fallback + output_message = getattr(response, "output_message", None) + if output_message is not None: + content = getattr(output_message, "content", None) + if content is not None: + return (content if isinstance(content, str) else str(content)), conversation_id + logger.warning( + "Response lacks output_message.content (conversation_id=%s)", + conversation_id, + ) + return "", conversation_id # fallback
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/app/endpoints/query.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-pr
- GitHub Check: e2e_tests
🔇 Additional comments (2)
src/app/endpoints/query.py (2)
495-497: Good defensive check prevents None dereferenceThe null-guard on response/output_message eliminates a crash path and aligns with the PR objective.
498-499: Confirm API behavior: empty string vs. error/metricReturning an empty string may mask upstream issues and be indistinguishable from a legitimate empty model output. Do we want to:
- increment a failure/empty-output metric here, or
- return a 502/500 to surface upstream issues?
If current behavior is intentional, consider documenting it in retrieve_response’s docstring.
df5012a to
7b0bdf2
Compare
7b0bdf2 to
1db7738
Compare
|
@CodeRabbit fullreview |
|
@tisnik I'll conduct a full review of all changes in this PR addressing the potential None reference handling bug fix. ✅ Actions performedFull review triggered. |
|
@coderabbitai generate unit tests |
|
An unexpected error occurred during Unit Test Generation. |
✅ Actions performedUnit Test Generation started... |
Description
LCORE-464: fix potential
Nonereference handlingType of change
Related Tickets & Documents
Summary by CodeRabbit