PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
22.65k stars 1k forks source link

PostgREST partially starts and does not return error when selecting an invalid file in `pgrst.jwt_secret` #3629

Open laurenceisla opened 2 days ago

laurenceisla commented 2 days ago

Description of issue

PostgREST does not fully load and does not print a useful error when an invalid file is selected for pgrst.jwt_secret. E.g. with this configuration:

create or replace function postgrest.pre_config()
returns void as $$
  select set_config('pgrst.jwt_secret', '@/does/not/exist', true);
$$ language sql;

Running PostgREST prints:

28/Jun/2024:21:22:50 -0500: Starting PostgREST 12.2.0...
28/Jun/2024:21:22:50 -0500: Admin server listening on port 3001
28/Jun/2024:21:22:50 -0500: Attempting to connect to the database...
28/Jun/2024:21:22:50 -0500: Listening on port 3000
28/Jun/2024:21:22:50 -0500: Successfully connected to PostgreSQL 15.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 12.3.0, 64-bit
28/Jun/2024:21:22:50 -0500: Listening for notifications on the "pgrst" channel

No schema cache/config logs and no error. A simple request returns this:

{"code":"PGRST002","details":null,"hint":null,"message":"Could not query the database for the schema cache. Retrying."}

This only fails for In-Database configurations, for ENV variables and Config files it prints the error correctly:

postgrest: /does/not/exist: withBinaryFile: does not exist (No such file or directory)