diff --git a/CHANGELOG.md b/CHANGELOG.md index b83e0207d..84cab3802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #3533, #3536, Fix listener silently failing on read replica - @steve-chavez + If the LISTEN connection fails, it's retried with exponential backoff - #3414, Force listener to connect to read-write instances using `target_session_attrs` - @steve-chavez + - #3255, Fix incorrect `413 Request Entity Too Large` on pg errors `54*` - @taimoorzaeem ### Deprecated diff --git a/docs/references/errors.rst b/docs/references/errors.rst index ba416a508..30a54c267 100644 --- a/docs/references/errors.rst +++ b/docs/references/errors.rst @@ -71,7 +71,7 @@ PostgREST translates `PostgreSQL error codes HTTP.status500 -- tx rollback "53400" -> HTTP.status500 -- config limit exceeded '5':'3':_ -> HTTP.status503 -- insufficient resources - '5':'4':_ -> HTTP.status413 -- too complex + '5':'4':_ -> HTTP.status500 -- too complex '5':'5':_ -> HTTP.status500 -- obj not on prereq state "57P01" -> HTTP.status503 -- terminating connection due to administrator command '5':'7':_ -> HTTP.status500 -- operator intervention diff --git a/test/spec/Feature/Query/ErrorSpec.hs b/test/spec/Feature/Query/ErrorSpec.hs index feeb7f78f..d004e5c5c 100644 --- a/test/spec/Feature/Query/ErrorSpec.hs +++ b/test/spec/Feature/Query/ErrorSpec.hs @@ -67,3 +67,15 @@ pgErrorCodeMapping = do describe "PostreSQL error code mappings" $ do it "should return 500 for cardinality_violation" $ get "/bad_subquery" `shouldRespondWith` 500 + + it "should return 500 for statement too complex" $ + request methodPost "/infinite_inserts" + [] + [json|{"id": 3, "name": "qwer"}|] + `shouldRespondWith` + [json| + {"code": "54001", + "details": null, + "hint": "Increase the configuration parameter \"max_stack_depth\" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.", + "message": "stack depth limit exceeded"}|] + { matchStatus = 500 } diff --git a/test/spec/fixtures/schema.sql b/test/spec/fixtures/schema.sql index 8b7458d67..fdb472bbd 100644 --- a/test/spec/fixtures/schema.sql +++ b/test/spec/fixtures/schema.sql @@ -3777,3 +3777,20 @@ 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'; + +-- https://github.com/PostgREST/postgrest/issues/3255 +create table test.infinite_inserts( + id int +, name text +); + +create or replace function infinite_inserts() +returns trigger as $$ begin + insert into infinite_inserts values (NEW.id, NEW.name); +end $$ language plpgsql; + +create trigger do_infinite_inserts +after insert +on infinite_inserts +for each row +execute procedure infinite_inserts();