Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config forbid same server-port and admin-server-port #3559

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #2052, Dropped support for PostgreSQL 9.6 - @wolfgangwalther
- #2052, Dropped support for PostgreSQL 10 - @wolfgangwalther
- #2052, Dropped support for PostgreSQL 11 - @wolfgangwalther
- #3508, #3559, Server port and admin server port can end up with the same value - @develop7
+ The app fails to start when the server port and admin server port are the same
develop7 marked this conversation as resolved.
Show resolved Hide resolved

## [12.2.0] - 2024-06-11

Expand Down
2 changes: 1 addition & 1 deletion docs/references/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ admin-server-port
**In-Database** `n/a`
=============== =======================

Specifies the port for the :ref:`admin_server`.
Specifies the port for the :ref:`admin_server`. Cannot be equal to :ref:`server-port`.

.. _app.settings.*:

Expand Down
11 changes: 10 additions & 1 deletion src/PostgREST/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,21 @@
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'

Check warning on line 227 in src/PostgREST/Config.hs

View check run for this annotation

Codecov / codecov/patch

src/PostgREST/Config.hs#L227

Added line #L227 was not covered by tests
develop7 marked this conversation as resolved.
Show resolved Hide resolved
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
develop7 marked this conversation as resolved.
Show resolved Hide resolved

decodeLoadFiles :: AppConfig -> IO AppConfig
decodeLoadFiles parsedConfig =
decodeJWKS <$>
Expand Down