-
Notifications
You must be signed in to change notification settings - Fork 336
Fix a few errors reported on sentry #6228
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
base: master
Are you sure you want to change the base?
Changes from all commits
bbed8b5
59ca3b5
6f8de42
664a8b2
a13ab0e
1e96d4a
6e6844a
df524ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,7 @@ async def search_text( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"search failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request searching for %r (path=%r, langs=%r): %s", | ||
| query, | ||
| path_filter, | ||
|
|
@@ -233,7 +233,7 @@ async def get_field_layout( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"field layout fetch failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error("Bad request fetching field layout for %r: %s", class_name, e) | ||
| logger.warning("Bad request fetching field layout for %r: %s", class_name, e) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we downgrading the log level? We can ignore it in Sentry until it spikes. Sentry supports that. |
||
| return _tool_error(f"field layout fetch failed: {e}") | ||
| except Exception as e: | ||
| logger.error("Unexpected error fetching field layout for %r: %s", class_name, e) | ||
|
|
@@ -265,7 +265,7 @@ async def get_blame( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"blame fetch failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request fetching blame for %r lines %r: %s", file_path, lines, e | ||
| ) | ||
| return _tool_error(f"blame fetch failed: {e}") | ||
|
|
@@ -304,7 +304,7 @@ async def check_can_gc( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"GC check failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error("Bad request checking GC status for %r: %s", symbol, e) | ||
| logger.warning("Bad request checking GC status for %r: %s", symbol, e) | ||
| return _tool_error(f"GC check failed: {e}") | ||
| except Exception as e: | ||
| logger.error("Unexpected error checking GC status for %r: %s", symbol, e) | ||
|
|
@@ -333,7 +333,7 @@ async def find_definition( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"definition lookup failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request finding definition for %r (path=%r): %s", name, path_filter, e | ||
| ) | ||
| return _tool_error(f"definition lookup failed: {e}") | ||
|
|
@@ -376,7 +376,7 @@ async def search_identifier( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"identifier search failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request searching for identifier %r (path=%r, langs=%r): %s", | ||
| identifier, | ||
| path_filter, | ||
|
|
@@ -408,7 +408,7 @@ async def calls_from( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"call graph fetch failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request fetching calls from %r (depth=%d): %s", symbol, depth, e | ||
| ) | ||
| return _tool_error(f"call graph fetch failed: {e}") | ||
|
|
@@ -436,7 +436,7 @@ async def calls_to( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"call graph fetch failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request fetching calls to %r (depth=%d): %s", symbol, depth, e | ||
| ) | ||
| return _tool_error(f"call graph fetch failed: {e}") | ||
|
|
@@ -468,7 +468,7 @@ async def calls_between( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"call graph fetch failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request fetching calls between %r and %r (depth=%d): %s", | ||
| symbol_a, | ||
| symbol_b, | ||
|
|
@@ -508,7 +508,7 @@ async def get_function_at_line( | |
| except SearchfoxNetworkError as e: | ||
| return _tool_error(f"function lookup failed: {e}") | ||
| except SearchfoxRequestError as e: | ||
| logger.error( | ||
| logger.warning( | ||
| "Bad request fetching function at line %d in %r: %s", line, file_path, e | ||
| ) | ||
| return _tool_error(f"function lookup failed: {e}") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from fastmcp.exceptions import ToolError | ||
|
|
||
|
|
||
| class RevisionNotFoundError(ToolError): | ||
| pass | ||
|
|
||
|
|
||
| class InvalidDocPathError(ToolError): | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from fastapi import APIRouter, Depends, status | ||
| from fastapi.responses import JSONResponse | ||
| from sqlalchemy import select | ||
| from sqlalchemy.exc import IntegrityError | ||
| from sqlalchemy.ext.asyncio import AsyncSession | ||
|
|
||
| from app.auth import verify_external_api_key | ||
|
|
@@ -80,7 +81,19 @@ async def create_or_get_review_request( | |
| status=ReviewStatus.PENDING, | ||
| ) | ||
| db.add(review_request) | ||
| await db.commit() | ||
| try: | ||
| await db.commit() | ||
| except IntegrityError: | ||
| await db.rollback() | ||
| existing_request = await db.scalar(stmt) | ||
| if existing_request is None: | ||
| raise | ||
| return JSONResponse( | ||
| { | ||
| "status": existing_request.status.value, | ||
| "message": _build_response_message(existing_request), | ||
| } | ||
| ) | ||
|
Comment on lines
-83
to
+96
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing this? We already have a mechanism to handle this and do the rollback on error in |
||
|
|
||
| schedule_time = ( | ||
| request.revision_created_at + INITIAL_TASK_DELAY | ||
|
|
||
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.
Do we have an error regarding this?