Skip to content

PGTARGET_SESSION_ATTRS is ignored, unlike every other option's PG<OPTION_NAME> variable #145

Open

Description

@okomarov

Every option that takes a string, number or boolean is read from PG + its name in upper case (PGSSL, PGIDLE_TIMEOUT, PGPARAMETER_TYPES and so on), except target_session_attrs.

The defaults loop in parseOptions reads PGTARGET_SESSION_ATTRS, but target_session_attrs: tsa(o, url, env) further down the same object literal overwrites it, and tsa() reads only libpq's PGTARGETSESSIONATTRS (src/index.js). So PGTARGET_SESSION_ATTRS=read-write is silently ignored, and the connection goes to any server.

Fix: tsa() also reads PGTARGET_SESSION_ATTRS, with libpq's PGTARGETSESSIONATTRS winning when both are set, and validates whichever value it uses. Add a test that sets only PGTARGET_SESSION_ATTRS.

Once this and #129 (PGMAX read as a string) are fixed, the convention holds for every such option. The environment variable table in docs/api.md (#141 lists one row per option) can then become libpq's names plus a single row for the PG<OPTION_NAME> rule. Accepting libpq's spellings where they differ, such as PGSSLMODE, is #125.

Activity

  1. added
    bug
    area: config
    on Oct 18, 2026
  2. moved this to Later in Roadmapon Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configbug

    Type

    No type

    Projects

    • Status
      Later

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions