You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/05/04 18:51:35 UTC

(tooling-trusted-releases) branch sbp updated: Add a regression test for API storage access error statuses

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new cdbeff0b Add a regression test for API storage access error statuses
cdbeff0b is described below

commit cdbeff0bbf9e21374c59720e9f0e52f630f680e8
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon May 4 19:51:10 2026 +0100

    Add a regression test for API storage access error statuses
---
 atr/server.py                 |  2 +-
 tests/unit/test_blueprints.py | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/atr/server.py b/atr/server.py
index f848d1df..b74c8484 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -984,7 +984,7 @@ async def _register_recurrent_tasks() -> None:
 
 
 def _register_routes(app: base.QuartApp) -> None:  # noqa: C901
-    # Add a global error handler to show helpful error messages with tracebacks
+    # Preserve HTTP status codes for errors that are raised outside blueprint-specific handlers
     @app.errorhandler(exceptions.HTTPException)
     async def handle_http_exception(error: exceptions.HTTPException) -> Any:
         status_code = error.code or 500
diff --git a/tests/unit/test_blueprints.py b/tests/unit/test_blueprints.py
index 84a75396..b6bb3817 100644
--- a/tests/unit/test_blueprints.py
+++ b/tests/unit/test_blueprints.py
@@ -16,16 +16,19 @@
 # under the License.
 
 import dataclasses
+import json
 from typing import Literal
 
 import asfquart
 import pytest
 
 import atr.blueprints as blueprints
+import atr.blueprints.api as api_blueprint
 import atr.blueprints.common as common
 import atr.form as form
 import atr.models.safe as safe
 import atr.models.schema as schema
+import atr.storage as storage
 import atr.util as util
 import atr.web as web
 
@@ -83,6 +86,19 @@ def test_build_api_path_body_param():
     assert body[1] is RequestBody
 
 
+@pytest.mark.asyncio
+async def test_api_storage_access_error_uses_embedded_status():
+    app = asfquart.construct("test-api-errors")
+
+    async with app.test_request_context("/api/test"):
+        response, status = await api_blueprint._handle_storage_access_error(
+            storage.AccessError("Release not found", status=404)
+        )
+
+    assert status == 404
+    assert json.loads(await response.data) == {"error": "Release not found"}
+
+
 def test_build_api_path_literal_and_safe():
     async def route(
         _session: web.Committer,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org