Conversation
…d_mcp_global_vars_from_config()
- Add FilenameExistsResponse model to SDK - Add filename_exists() async method to DocumentsClient - Add GET /v1/documents/check-filename endpoint with API key auth - Export FilenameExistsResponse in SDK __init__.py This enables SDK users to check if a file exists in the knowledge base before ingestion, avoiding duplicate uploads.
| if "AuthenticationException" in error_str or "access denied" in error_str.lower(): | ||
| return JSONResponse({"error": "Access denied: insufficient permissions"}, status_code=403) | ||
| else: | ||
| return JSONResponse({"error": str(e)}, status_code=500) |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
In general, to fix this problem we should avoid returning raw exception messages to the client. Instead, log the actual exception (possibly with stack trace) on the server, and send a generic, non-sensitive error message in the HTTP response. This preserves debuggability while preventing information disclosure.
For this specific endpoint in src/api/v1/documents.py, we should keep the existing special handling for authentication errors (lines 150–151), but for the generic else branch at line 153, replace {"error": str(e)} with a constant, generic error string like {"error": "Internal server error"} or similar. The detailed error is already logged at line 148 (logger.error(..., error=str(e))), so we only need to change what is returned to the client.
Concretely:
- In
check_filename_exists_endpoint, leave theexcept Exception as e:block structure and logging intact. - In the
elsebranch starting at line 152, change the JSONResponse body from{"error": str(e)}to a generic message such as{"error": "An internal error occurred while checking filename existence"}(or similarly neutral wording). - No new imports or helper methods are required because the
loggeris already used andJSONResponseis already imported.
| @@ -150,4 +150,7 @@ | ||
| if "AuthenticationException" in error_str or "access denied" in error_str.lower(): | ||
| return JSONResponse({"error": "Access denied: insufficient permissions"}, status_code=403) | ||
| else: | ||
| return JSONResponse({"error": str(e)}, status_code=500) | ||
| return JSONResponse( | ||
| {"error": "An internal error occurred while checking filename existence"}, | ||
| status_code=500, | ||
| ) |
…to sdk_for_ragworkbench
- Add inference and ingest pipelines - Add create_boards script and utility modules (utils, logging_config) - Add .env.example for configuration - add pyproject.toml
- Add shared conftest.py with environment and logging fixtures - Enhance inference test with explicit cache hit/miss validation - Update pytest configuration with pythonpath and strict markers
- Add boards module with table_rich board configuration - Rename create_boards.py to evaluate.py for clarity - Enhance .gitignore with additional patterns - Remove unused imports from pipelines - Update utility functions
No description provided.