fix: clarify error for failed schema cache load

This commit is contained in:
steve-chavez
2022-01-07 09:31:30 +01:00
committed by Wolfgang Walther
parent aa82d2e277
commit 51ee072f84
4 changed files with 12 additions and 5 deletions
+2
View File
@@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #2077, Fix `is` not working with upper or mixed case values like `NULL, TrUe, FaLsE` - @steve-chavez
- #2024, Fix schema cache loading when views with XMLTABLE and DEFAULT are present - @wolfgangwalther
- #1724, Fix wrong CORS header Authentication -> Authorization - @wolfgangwalther
- #2107, Clarify error for failed schema cache load. - @steve-chavez
+ From `Database connection lost. Retrying the connection` to `Could not query the database for the schema cache. Retrying.`
## [9.0.0] - 2021-11-25
+1 -1
View File
@@ -191,7 +191,7 @@ postgrestResponse conf maybeDbStructure jsonDbS pgVer pool time req = do
Just dbStructure ->
return dbStructure
Nothing ->
throwError Error.ConnectionLostError
throwError Error.NoSchemaCacheError
apiRequest@ApiRequest{..} <-
liftEither . mapLeft Error.ApiRequestError $
+4 -4
View File
@@ -280,7 +280,7 @@ data Error
= GucHeadersError
| GucStatusError
| BinaryFieldError ContentType
| ConnectionLostError
| NoSchemaCacheError
| PutMatchingPkError
| PutRangeNotAllowedError
| JwtTokenMissing
@@ -294,7 +294,7 @@ instance PgrstError Error where
status GucHeadersError = HTTP.status500
status GucStatusError = HTTP.status500
status (BinaryFieldError _) = HTTP.status406
status ConnectionLostError = HTTP.status503
status NoSchemaCacheError = HTTP.status503
status PutMatchingPkError = HTTP.status400
status PutRangeNotAllowedError = HTTP.status400
status JwtTokenMissing = HTTP.status500
@@ -317,8 +317,8 @@ instance JSON.ToJSON Error where
"message" .= ("response.status guc must be a valid status code" :: Text)]
toJSON (BinaryFieldError ct) = JSON.object [
"message" .= ((T.decodeUtf8 (ContentType.toMime ct) <> " requested but more than one column was selected") :: Text)]
toJSON ConnectionLostError = JSON.object [
"message" .= ("Database connection lost. Retrying the connection." :: Text)]
toJSON NoSchemaCacheError = JSON.object [
"message" .= ("Could not query the database for the schema cache. Retrying." :: Text)]
toJSON PutRangeNotAllowedError = JSON.object [
"message" .= ("Range header and limit/offset querystring parameters are not allowed for PUT" :: Text)]
+5
View File
@@ -787,12 +787,17 @@ def test_admin_ready_includes_schema_cache_state(defaultenv):
"/rpc/no_schema_cache_for_limited_authenticator"
)
assert response.status_code == 200
# force a reconnection so the new role setting is picked up
postgrest.process.send_signal(signal.SIGUSR1)
time.sleep(0.1)
response = postgrest.admin.get("/ready")
assert response.status_code == 503
response = postgrest.session.get("/projects")
assert response.status_code == 503
def test_admin_not_found(defaultenv):
"Should get a not found from a undefined endpoint on the admin server"