kiba-core 0.5.3.dev94__tar.gz → 0.5.3.dev96__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/CHANGELOG.md +2 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/PKG-INFO +1 -1
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/database_connection_middleware.py +6 -2
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/exception_handling_middleware.py +3 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/kiba_core.egg-info/PKG-INFO +1 -1
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/pyproject.toml +1 -1
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_database_connection_middleware.py +22 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_exception_handling_middleware.py +21 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.github/pull_request_template.md +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.github/workflows/deploy.yml +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.github/workflows/publish.yml +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.github/workflows/pull-request.yml +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.github/workflows/release.yml +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/.gitignore +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/Dockerfile +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/README.md +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/api_request.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/api_response.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/authorizer.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/default_routes.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/health.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/json_route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/logging_middleware.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/origin_ip_middleware.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/server_headers_middleware.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/openapi.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/rate_limit.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/request_body.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/request_context.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/route_auth.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/route_metadata.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/streaming_json_route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/uploaded_file.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/aws_requester.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/caching/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/caching/cache.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/caching/dict_cache.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/caching/file_cache.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/cron/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/cron/api_request_cron_job_processor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/cron/cron_executor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/cron/cron_job_processor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/cron/model.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/exceptions.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/http/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/http/basic_authentication.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/http/jwt.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/http/rest_method.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/locks/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/locks/lock.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/locks/model.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/locks/sql.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/logging.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/notifications/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/notifications/discord_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/notifications/notification_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/notifications/slack_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/py.typed +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/aqs.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/cosmos.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/message_queue.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/message_queue_processor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/model.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/sql.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/queues/sqs.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/requester/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/requester/requester.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/s3_manager.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/service_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/store/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/store/database.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/store/entity_repository.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/store/retriever.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/store/saver.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/async_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/chain_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/date_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/dict_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/file_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/hashing_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/http_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/json_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/list_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/process_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/string_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/typing_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/url_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/util/value_holder.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/web3/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/web3/eth_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/web3/eth_client_registry.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/web3/multicall3.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/kiba_core.egg-info/SOURCES.txt +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/kiba_core.egg-info/dependency_links.txt +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/kiba_core.egg-info/requires.txt +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/kiba_core.egg-info/top_level.txt +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/makefile +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/setup.cfg +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_api_response.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_authorizer.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_json_route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_openapi.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_origin_ip_middleware.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_rate_limit.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_request_context.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_streaming_json_route.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/caching/test_dict_cache.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/caching/test_file_cache.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/cron/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/cron/test_cron_executor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/locks/test_sql_lock.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/conftest.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_aqs_queue.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_cosmos_queue.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_message_queue_processor.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_sql_queue.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_sqs_queue.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/requester/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/requester/test_requester.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/test_database.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/test_entity_repository.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/test_exceptions.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/test_logging.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_async_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_chain_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_date_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_dict_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_file_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_json_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_list_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_process_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_string_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/util/test_url_util.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/web3/__init__.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/web3/test_eth_client_registry.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/web3/test_rest_eth_client.py +0 -0
- {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/uv.lock +0 -0
|
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
|
+
- [MINOR] Added `excludedPaths` (exact) and `excludedPathPrefixes` to `DatabaseConnectionMiddleware`: matching requests run without a context connection, e.g. a long-lived SSE stream that shouldn't hold a pooled connection and open transaction, or routes that use a different database
|
|
12
|
+
- [PATCH] Updated `ExceptionHandlingMiddleware` to answer a client that disconnects before the response starts (starlette's `ClientDisconnect`, e.g. while reading the body) with a 499 instead of logging a traceback and a 500
|
|
11
13
|
- [MAJOR] Added `priority` to `SqlMessageQueue.send_message` and `send_messages` (default 0): visible messages are claimed highest priority first, then by `visibleDate`, and a duplicate send, or a retry folded into a pending duplicate, keeps the higher priority. `tbl_queue_messages` has a new `priority` column (`INTEGER NOT NULL DEFAULT 0`), so apps must add it with a migration before upgrading
|
|
12
14
|
- [PATCH] Fixed `DatabaseConnectionMiddleware`'s commit when the response starts failing ("another operation is in progress") for streaming responses behind a `BaseHTTPMiddleware`: `Database.execute` and `Database.commit_context_connection` now wait for each other on the same connection
|
|
13
15
|
- [MINOR] Added `Database.commit_context_connection` to commit the context connection's writes so far; anything run on it afterwards is committed when the context connection ends
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from collections.abc import Collection
|
|
2
|
+
|
|
1
3
|
from starlette.types import ASGIApp
|
|
2
4
|
from starlette.types import Message
|
|
3
5
|
from starlette.types import Receive
|
|
@@ -8,14 +10,16 @@ from core.store.database import Database
|
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
class DatabaseConnectionMiddleware:
|
|
11
|
-
def __init__(self, app: ASGIApp, database: Database) -> None:
|
|
13
|
+
def __init__(self, app: ASGIApp, database: Database, excludedPaths: Collection[str] = (), excludedPathPrefixes: Collection[str] = ()) -> None:
|
|
12
14
|
self.app = app
|
|
13
15
|
self.database = database
|
|
16
|
+
self.excludedPaths = frozenset(excludedPaths)
|
|
17
|
+
self.excludedPathPrefixes = tuple(excludedPathPrefixes)
|
|
14
18
|
|
|
15
19
|
# NOTE(krishan711): see note in database.py about why this can cause problems with concurrent operations
|
|
16
20
|
# NOTE(krishan711): raw ASGI (not BaseHTTPMiddleware) so the DB connection stays open across streaming body
|
|
17
21
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
18
|
-
if scope['type'] != 'http':
|
|
22
|
+
if scope['type'] != 'http' or scope['path'] in self.excludedPaths or scope['path'].startswith(self.excludedPathPrefixes):
|
|
19
23
|
await self.app(scope, receive, send)
|
|
20
24
|
return
|
|
21
25
|
async with self.database.create_context_connection():
|
{kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/exception_handling_middleware.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from starlette.middleware.base import BaseHTTPMiddleware
|
|
2
2
|
from starlette.middleware.base import RequestResponseEndpoint
|
|
3
|
+
from starlette.requests import ClientDisconnect
|
|
3
4
|
from starlette.requests import Request
|
|
4
5
|
from starlette.responses import Response
|
|
5
6
|
from starlette.types import ASGIApp
|
|
@@ -29,6 +30,8 @@ class ExceptionHandlingMiddleware(BaseHTTPMiddleware):
|
|
|
29
30
|
except RedirectException as exception:
|
|
30
31
|
response = Response(status_code=exception.statusCode)
|
|
31
32
|
response.headers.update(exception.outgoing_headers())
|
|
33
|
+
except ClientDisconnect:
|
|
34
|
+
response = Response(status_code=499)
|
|
32
35
|
except ClientException as exception:
|
|
33
36
|
if self.shouldSquashClientExceptions:
|
|
34
37
|
logging.error(f'{exception.exceptionType} occurred: {exception.message}')
|
{kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_database_connection_middleware.py
RENAMED
|
@@ -99,6 +99,28 @@ async def test_writes_are_rolled_back_when_the_request_fails_before_responding(d
|
|
|
99
99
|
assert await get_record_names(database=database) == []
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
@pytest.mark.asyncio
|
|
103
|
+
@pytest.mark.parametrize(('path', 'isExcluded'), [('/live-events', True), ('/live-events/123', False), ('/mcp', True), ('/mcp/exports/token', True), ('/v1/mcp', False), ('/', False)])
|
|
104
|
+
async def test_excluded_paths_run_without_a_context_connection(database, path, isExcluded):
|
|
105
|
+
hasContextConnectionHolder: list[bool] = []
|
|
106
|
+
|
|
107
|
+
async def app(scope, receive, send):
|
|
108
|
+
hasContextConnectionHolder.append(database._get_context_connection() is not None)
|
|
109
|
+
await send({'type': 'http.response.start', 'status': 200, 'headers': []})
|
|
110
|
+
await send({'type': 'http.response.body', 'body': b'ok'})
|
|
111
|
+
|
|
112
|
+
async def receive():
|
|
113
|
+
return {'type': 'http.request', 'body': b'', 'more_body': False}
|
|
114
|
+
|
|
115
|
+
async def send(message):
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
middleware = DatabaseConnectionMiddleware(app=app, database=database, excludedPaths={'/live-events'}, excludedPathPrefixes=('/mcp',))
|
|
119
|
+
await middleware({'type': 'http', 'method': 'GET', 'path': path}, receive, send)
|
|
120
|
+
|
|
121
|
+
assert hasContextConnectionHolder == [not isExcluded]
|
|
122
|
+
|
|
123
|
+
|
|
102
124
|
async def post_to_app(app) -> tuple[int, bytes]:
|
|
103
125
|
scope = {
|
|
104
126
|
'type': 'http', 'asgi': {'version': '3.0'}, 'http_version': '1.1', 'method': 'POST', 'scheme': 'http', 'path': '/', 'raw_path': b'/',
|
{kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/api/test_exception_handling_middleware.py
RENAMED
|
@@ -119,3 +119,24 @@ def test_plain_exception_has_no_extra_headers(plain_error_client):
|
|
|
119
119
|
assert response.status_code == 400
|
|
120
120
|
assert 'retry-after' not in response.headers
|
|
121
121
|
assert 'location' not in response.headers
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@pytest.mark.asyncio
|
|
125
|
+
async def test_client_disconnect_while_reading_body_returns_499():
|
|
126
|
+
@json_route(requestType=SimpleRequest, responseType=SimpleResponse)
|
|
127
|
+
async def endpoint(request: KibaApiRequest[SimpleRequest]) -> SimpleResponse:
|
|
128
|
+
return SimpleResponse(result=request.data.value)
|
|
129
|
+
|
|
130
|
+
app = Starlette(routes=[Route('/echo', endpoint, methods=['POST'])])
|
|
131
|
+
app.add_middleware(ExceptionHandlingMiddleware)
|
|
132
|
+
sentMessages = []
|
|
133
|
+
|
|
134
|
+
async def receive():
|
|
135
|
+
return {'type': 'http.disconnect'}
|
|
136
|
+
|
|
137
|
+
async def send(message):
|
|
138
|
+
sentMessages.append(message)
|
|
139
|
+
|
|
140
|
+
scope = {'type': 'http', 'asgi': {'version': '3.0'}, 'method': 'POST', 'path': '/echo', 'headers': [(b'content-type', b'application/json')], 'query_string': b''}
|
|
141
|
+
await app(scope, receive, send)
|
|
142
|
+
assert sentMessages[0]['status'] == 499
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/core/api/middleware/server_headers_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev96}/tests/queues/test_message_queue_processor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|