Skip to content

Test new sdk#10

Draft
matanor wants to merge 62 commits intomainfrom
test_new_sdk
Draft

Test new sdk#10
matanor wants to merge 62 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 1 day ago

In general, to fix this issue we should stop returning the raw exception message to the client. Instead, we should log the full error on the server (as is already done) and return a generic, user-safe error message. If we need to preserve some notion of what went wrong, we can use a high-level description that does not include internal system details, and optionally include a generic error code.

For this specific file, the minimal change that preserves existing behavior is to modify the except Exception as e: block in check_filename_exists_endpoint. We will continue to log the detailed error via logger.error(...) but change the else branch from {"error": str(e)} to a generic message like {"error": "Internal server error while checking filename existence"}. This keeps the control-flow and status codes intact (403 for access issues, 500 for everything else) while eliminating exposure of the raw exception text.

Concretely:

  • Edit src/api/v1/documents.py, in the check_filename_exists_endpoint function.
  • In the outer except Exception as e: block (around lines 127–133), keep the logging and the 403 response as-is, but replace the 500 response body to avoid including str(e).
  • No new imports or helper methods are required.
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
@@ -130,4 +130,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": "Internal server error while checking filename existence"},
+                status_code=500,
+            )
EOF
@@ -130,4 +130,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": "Internal server error while checking filename existence"},
status_code=500,
)
Copilot is powered by AI and may make mistakes. Always verify output.
matanor and others added 29 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.

2 participants