diff --git a/CHANGELOG.md b/CHANGELOG.md index bfbe9e708e..ecc39ec08a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #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 - #3549, Remove verbosity from error logs starting with "An error occurred..." and replacing it with "Failed to..." - @laurenceisla + - #3508, Server port and admin server port can end up with the same value - @develop7 + + The app is fails to start when the server port and admin server port are the same ### Deprecated diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index 4a885c7f67..92f741880a 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -223,12 +223,21 @@ readAppConfig dbSettings optPath prevDbUri roleSettings roleIsolationLvl = do Left err -> return . Left $ "Error in config " <> err Right parsedConfig -> - Right <$> decodeLoadFiles parsedConfig + case processForbiddenValues parsedConfig of + Left err' -> + return . Left $ "Error in config " <> err' + Right config -> + Right <$> decodeLoadFiles config where -- Both C.ParseError and IOError are shown here loadConfig :: FilePath -> IO (Either SomeException C.Config) loadConfig = try . C.load + processForbiddenValues :: AppConfig -> Either Text AppConfig + processForbiddenValues cfg@AppConfig{..} + | configAdminServerPort == Just configServerPort = Left "admin-server-port cannot be the same as server-port" + | otherwise = Right cfg + decodeLoadFiles :: AppConfig -> IO AppConfig decodeLoadFiles parsedConfig = decodeJWKS <$>