feat: add Proxy-Status header for better error response

This commit is contained in:
Taimoor Zaeem
2025-04-05 13:43:39 -05:00
committed by GitHub
parent 2811d6f997
commit f7f87b42ca
6 changed files with 102 additions and 5 deletions
+20
View File
@@ -1830,3 +1830,23 @@ def test_log_pool_req_observation(level, defaultenv):
else:
output = postgrest.read_stdout(nlines=4)
assert len(output) == 0
def test_proxy_status_header(defaultenv, metapostgrest):
"Test Proxy-Status header in statement timeout error"
role = "timeout_authenticator"
set_statement_timeout(metapostgrest, role, 1000) # 1 second
env = {
**defaultenv,
"PGUSER": role,
"PGRST_DB_ANON_ROLE": role,
}
with run(env=env) as postgrest:
response = postgrest.session.get("/rpc/sleep?seconds=2")
assert response.status_code == 500
assert response.headers["Proxy-Status"] == "PostgREST; error=57014"
data = response.json()
assert data["message"] == "canceling statement due to statement timeout"