diff --git a/CHANGELOG.md b/CHANGELOG.md index 67debfab91..e1e8642fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #3373, Remove rejected mediatype `application/vnd.pgrst.object+json` from response - @taimoorzaeem - #3418, Fix OpenAPI not tagging a FK column correctly on O2O relationships - @laurenceisla - #3256, Fix wrong http status for pg error `42P17 infinite recursion` - @taimoorzaeem + - #3267, Fix wrong `503 Service Unavailable` on pg error `53400` - @taimoorzaeem ### Deprecated diff --git a/src/PostgREST/Error.hs b/src/PostgREST/Error.hs index 31288bf83c..488a1c6c3b 100644 --- a/src/PostgREST/Error.hs +++ b/src/PostgREST/Error.hs @@ -474,7 +474,7 @@ pgErrorStatus authed (SQL.SessionUsageError (SQL.QueryError _ _ (SQL.ResultError '3':'9':_ -> HTTP.status500 -- external routine invocation '3':'B':_ -> HTTP.status500 -- savepoint exception '4':'0':_ -> HTTP.status500 -- tx rollback - '5':'3':_ -> HTTP.status503 -- insufficient resources + '5':'3':_ -> HTTP.status500 -- insufficient resources '5':'4':_ -> HTTP.status413 -- too complex '5':'5':_ -> HTTP.status500 -- obj not on prereq state '5':'7':'P':'0':'1':_ -> HTTP.status503 -- terminating connection due to administrator command diff --git a/test/spec/Feature/Query/RpcSpec.hs b/test/spec/Feature/Query/RpcSpec.hs index 4887e8face..4edfa38d08 100644 --- a/test/spec/Feature/Query/RpcSpec.hs +++ b/test/spec/Feature/Query/RpcSpec.hs @@ -1466,3 +1466,10 @@ spec actualPgVersion = get "/rpc/raise_sqlstate_missing_details" `shouldRespondWith` [json|{"code":"PGRST121","message":"The message and detail field of RAISE 'PGRST' error expects JSON","details":null,"hint":null}|] { matchStatus = 500 } + + context "test function temp_file_limit" $ + let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXN0X3Rlc3Rfc3VwZXJ1c2VyIiwiaWQiOiJqZG9lIn0.LQ-qx0ArBnfkwQQhIHKF5cS-lzl0gnTPI8NLoPbL5Fg" in + it "should return http status 500" $ + request methodGet "/rpc/temp_file_limit" [auth] "" `shouldRespondWith` + [json|{"code":"53400","message":"temporary file size exceeds temp_file_limit (1kB)","details":null,"hint":null}|] + { matchStatus = 500 } diff --git a/test/spec/fixtures/roles.sql b/test/spec/fixtures/roles.sql index a628bf1e07..3590c6edbc 100644 --- a/test/spec/fixtures/roles.sql +++ b/test/spec/fixtures/roles.sql @@ -1,6 +1,7 @@ -DROP ROLE IF EXISTS postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author; +DROP ROLE IF EXISTS postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author, postgrest_test_superuser; CREATE ROLE postgrest_test_anonymous; CREATE ROLE postgrest_test_default_role; CREATE ROLE postgrest_test_author; +CREATE ROLE postgrest_test_superuser WITH SUPERUSER; -GRANT postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author TO :PGUSER; +GRANT postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author, postgrest_test_superuser TO :PGUSER; diff --git a/test/spec/fixtures/schema.sql b/test/spec/fixtures/schema.sql index e8d0f848da..8b7458d676 100644 --- a/test/spec/fixtures/schema.sql +++ b/test/spec/fixtures/schema.sql @@ -3771,3 +3771,9 @@ select * from test.projects; create or replace view test.infinite_recursion as select * from test.infinite_recursion; + + +create or replace function temp_file_limit() +returns bigint as $$ + select COUNT(*) FROM generate_series('-infinity'::TIMESTAMP, 'epoch'::TIMESTAMP, INTERVAL '1 DAY'); +$$ language sql security definer set temp_file_limit to '1kB';