kiba-core 0.5.3.dev94__tar.gz → 0.5.3.dev95__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.
Files changed (146) hide show
  1. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/CHANGELOG.md +1 -0
  2. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/PKG-INFO +1 -1
  3. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/exception_handling_middleware.py +3 -0
  4. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/kiba_core.egg-info/PKG-INFO +1 -1
  5. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/pyproject.toml +1 -1
  6. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_exception_handling_middleware.py +21 -0
  7. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.github/pull_request_template.md +0 -0
  8. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.github/workflows/deploy.yml +0 -0
  9. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.github/workflows/publish.yml +0 -0
  10. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.github/workflows/pull-request.yml +0 -0
  11. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.github/workflows/release.yml +0 -0
  12. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/.gitignore +0 -0
  13. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/Dockerfile +0 -0
  14. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/README.md +0 -0
  15. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/__init__.py +0 -0
  16. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/__init__.py +0 -0
  17. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/api_request.py +0 -0
  18. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/api_response.py +0 -0
  19. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/authorizer.py +0 -0
  20. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/default_routes.py +0 -0
  21. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/health.py +0 -0
  22. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/json_route.py +0 -0
  23. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/__init__.py +0 -0
  24. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/database_connection_middleware.py +0 -0
  25. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/logging_middleware.py +0 -0
  26. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/origin_ip_middleware.py +0 -0
  27. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/middleware/server_headers_middleware.py +0 -0
  28. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/openapi.py +0 -0
  29. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/rate_limit.py +0 -0
  30. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/request_body.py +0 -0
  31. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/request_context.py +0 -0
  32. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/route.py +0 -0
  33. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/route_auth.py +0 -0
  34. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/route_metadata.py +0 -0
  35. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/streaming_json_route.py +0 -0
  36. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/api/uploaded_file.py +0 -0
  37. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/aws_requester.py +0 -0
  38. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/caching/__init__.py +0 -0
  39. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/caching/cache.py +0 -0
  40. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/caching/dict_cache.py +0 -0
  41. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/caching/file_cache.py +0 -0
  42. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/cron/__init__.py +0 -0
  43. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/cron/api_request_cron_job_processor.py +0 -0
  44. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/cron/cron_executor.py +0 -0
  45. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/cron/cron_job_processor.py +0 -0
  46. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/cron/model.py +0 -0
  47. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/exceptions.py +0 -0
  48. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/http/__init__.py +0 -0
  49. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/http/basic_authentication.py +0 -0
  50. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/http/jwt.py +0 -0
  51. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/http/rest_method.py +0 -0
  52. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/locks/__init__.py +0 -0
  53. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/locks/lock.py +0 -0
  54. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/locks/model.py +0 -0
  55. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/locks/sql.py +0 -0
  56. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/logging.py +0 -0
  57. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/notifications/__init__.py +0 -0
  58. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/notifications/discord_client.py +0 -0
  59. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/notifications/notification_client.py +0 -0
  60. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/notifications/slack_client.py +0 -0
  61. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/py.typed +0 -0
  62. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/__init__.py +0 -0
  63. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/aqs.py +0 -0
  64. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/cosmos.py +0 -0
  65. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/message_queue.py +0 -0
  66. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/message_queue_processor.py +0 -0
  67. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/model.py +0 -0
  68. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/sql.py +0 -0
  69. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/queues/sqs.py +0 -0
  70. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/requester/__init__.py +0 -0
  71. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/requester/requester.py +0 -0
  72. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/s3_manager.py +0 -0
  73. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/service_client.py +0 -0
  74. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/store/__init__.py +0 -0
  75. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/store/database.py +0 -0
  76. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/store/entity_repository.py +0 -0
  77. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/store/retriever.py +0 -0
  78. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/store/saver.py +0 -0
  79. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/__init__.py +0 -0
  80. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/async_util.py +0 -0
  81. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/chain_util.py +0 -0
  82. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/date_util.py +0 -0
  83. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/dict_util.py +0 -0
  84. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/file_util.py +0 -0
  85. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/hashing_util.py +0 -0
  86. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/http_util.py +0 -0
  87. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/json_util.py +0 -0
  88. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/list_util.py +0 -0
  89. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/process_util.py +0 -0
  90. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/string_util.py +0 -0
  91. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/typing_util.py +0 -0
  92. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/url_util.py +0 -0
  93. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/util/value_holder.py +0 -0
  94. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/web3/__init__.py +0 -0
  95. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/web3/eth_client.py +0 -0
  96. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/web3/eth_client_registry.py +0 -0
  97. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/core/web3/multicall3.py +0 -0
  98. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/kiba_core.egg-info/SOURCES.txt +0 -0
  99. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/kiba_core.egg-info/dependency_links.txt +0 -0
  100. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/kiba_core.egg-info/requires.txt +0 -0
  101. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/kiba_core.egg-info/top_level.txt +0 -0
  102. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/makefile +0 -0
  103. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/setup.cfg +0 -0
  104. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/__init__.py +0 -0
  105. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_api_response.py +0 -0
  106. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_authorizer.py +0 -0
  107. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_database_connection_middleware.py +0 -0
  108. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_json_route.py +0 -0
  109. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_openapi.py +0 -0
  110. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_origin_ip_middleware.py +0 -0
  111. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_rate_limit.py +0 -0
  112. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_request_context.py +0 -0
  113. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_route.py +0 -0
  114. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/api/test_streaming_json_route.py +0 -0
  115. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/caching/test_dict_cache.py +0 -0
  116. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/caching/test_file_cache.py +0 -0
  117. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/cron/__init__.py +0 -0
  118. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/cron/test_cron_executor.py +0 -0
  119. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/locks/test_sql_lock.py +0 -0
  120. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/conftest.py +0 -0
  121. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/test_aqs_queue.py +0 -0
  122. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/test_cosmos_queue.py +0 -0
  123. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/test_message_queue_processor.py +0 -0
  124. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/test_sql_queue.py +0 -0
  125. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/queues/test_sqs_queue.py +0 -0
  126. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/requester/__init__.py +0 -0
  127. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/requester/test_requester.py +0 -0
  128. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/test_database.py +0 -0
  129. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/test_entity_repository.py +0 -0
  130. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/test_exceptions.py +0 -0
  131. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/test_logging.py +0 -0
  132. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/__init__.py +0 -0
  133. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_async_util.py +0 -0
  134. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_chain_util.py +0 -0
  135. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_date_util.py +0 -0
  136. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_dict_util.py +0 -0
  137. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_file_util.py +0 -0
  138. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_json_util.py +0 -0
  139. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_list_util.py +0 -0
  140. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_process_util.py +0 -0
  141. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_string_util.py +0 -0
  142. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/util/test_url_util.py +0 -0
  143. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/web3/__init__.py +0 -0
  144. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/web3/test_eth_client_registry.py +0 -0
  145. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/tests/web3/test_rest_eth_client.py +0 -0
  146. {kiba_core-0.5.3.dev94 → kiba_core-0.5.3.dev95}/uv.lock +0 -0
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8
8
  ## [Unreleased]
9
9
 
10
10
  ### Added
11
+ - [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
12
  - [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
13
  - [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
14
  - [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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kiba-core
3
- Version: 0.5.3.dev94
3
+ Version: 0.5.3.dev95
4
4
  Summary: Kiba Labs' python utilities
5
5
  Project-URL: repository, https://github.com/kibalabs/core-py
6
6
  Requires-Python: <4,>=3.12
@@ -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}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kiba-core
3
- Version: 0.5.3.dev94
3
+ Version: 0.5.3.dev95
4
4
  Summary: Kiba Labs' python utilities
5
5
  Project-URL: repository, https://github.com/kibalabs/core-py
6
6
  Requires-Python: <4,>=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kiba-core"
3
- version = "0.5.3.dev94"
3
+ version = "0.5.3.dev95"
4
4
  description = "Kiba Labs' python utilities"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12, <4"
@@ -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