Skip to content

Test new sdk#10

Draft
matanor wants to merge 55 commits intomainfrom
test_new_sdk
Draft

Test new sdk#10
matanor wants to merge 55 commits intomainfrom
test_new_sdk

Conversation

@matanor
Copy link
Owner

@matanor matanor commented Mar 11, 2026

No description provided.

- 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

Stack trace information
flows to this location and may be exposed to an external user.

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 the except Exception as e: block structure and logging intact.
  • In the else branch 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 logger is already used and JSONResponse is already imported.
Suggested changeset 1
src/api/v1/documents.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/api/v1/documents.py b/src/api/v1/documents.py
--- a/src/api/v1/documents.py
+++ b/src/api/v1/documents.py
@@ -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,
+            )
EOF
@@ -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,
)
Copilot is powered by AI and may make mistakes. Always verify output.
matanor added 22 commits March 11, 2026 14:49
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant