Skip to content

Using PGREST_DB_PRE_CONFIG w/out the underlying config function yields a confusing error #4380

@zvozin

Description

@zvozin

Environment

  • PostgreSQL version: postgres:17
  • PostgREST version: postgrest/postgrest:v13.0.7
  • Operating system: Docker Desktop 4.26.1 on Mac OS 15.1.1

Description of issue

Describe the behavior you expected vs the actual behavior. Include:

This on startup:

pg         | 2025-10-03 21:48:33.517 UTC [51] LOG:  unexpected EOF on client connection with an open transaction
postgrest exited with code 1
postgrest  | 03/Oct/2025:21:48:35 +0000: Listening for database notifications on the "pgrst" channel
postgrest  | 03/Oct/2025:21:48:35 +0000: Successfully connected to PostgreSQL 17.6 (Debian 17.6-2.pgdg13+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
postgrest  | 03/Oct/2025:21:48:35 +0000: Connection Pool initialized with a maximum size of 15 connections
pg         | 2025-10-03 21:48:35.276 UTC [53] ERROR:  syntax error at or near "true" at character 566
pg         | 2025-10-03 21:48:35.276 UTC [53] STATEMENT:  WITH
pg         |    role_setting AS (
pg         |      SELECT setdatabase as database,
pg         |             unnest(setconfig) as setting
pg         |      FROM pg_catalog.pg_db_role_setting
pg         |      WHERE setrole = CURRENT_USER::regrole::oid
pg         |        AND setdatabase IN (0, (SELECT oid FROM pg_catalog.pg_database WHERE datname = CURRENT_CATALOG))
pg         |    ),
pg         |    kv_settings AS (
pg         |      SELECT database,
pg         |             substr(setting, 1, strpos(setting, '=') - 1) as k,
pg         |             substr(setting, strpos(setting, '=') + 1) as v
pg         |      FROM role_setting
pg         |      UNION
pg         |      SELECT
pg         |        null as database,
pg         |        x as k,
pg         |        current_setting(x, true) as v
pg         |      FROM unnest($1) x
pg         |      JOIN true() _ ON TRUE
pg         |    )
pg         |    SELECT DISTINCT ON (key)
pg         |           replace(k, 'pgrst.', '') AS key,
pg         |           v AS value
pg         |    FROM kv_settings
pg         |    WHERE k = ANY($1) AND v IS NOT NULL
pg         |    ORDER BY key, database DESC NULLS LAST;
postgrest  | 03/Oct/2025:21:48:35 +0000: This is probably a bug in PostgREST, please report it at https://github.com/PostgREST/postgrest/issues. {"code":"42601","details":null,"hint":null,"message":"syntax error at or near \"true\""}
postgrest  | 03/Oct/2025:21:48:35 +0000: Failed to query database settings for the config parameters.{"code":"42601","details":null,"hint":null,"message":"syntax error at or near \"true\""}
postgrest  | postgrest: thread killed

Discovered by having ChatGPT through in a gratuitous PGREST_DB_PRE_CONFIG into a docker-compose.yaml where it had no business being.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configrelated to the configuration optionsmessagesuser-facing error/informative messages

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions