Skip to content

fix(authserver): client management create, update and list filters fail on PostgreSQL's enum columns; H2 create writes missing columns #351

Backlog

Description

@dfcoffin

Found in the round-1 review of #350 (#345). Pre-existing; for #344 part 3.

Problem

On PostgreSQL, oauth2_registered_client.client_status is the enum type client_status_type and security_level is security_level_type (PostgreSQL V2_0_0__add_espi4_compliance_enhancements.sql). PostgreSQL refuses a text parameter for an enum column ("column ... is of type client_status_type but expression is of type character varying"), and a comparison of an enum column with a text parameter fails the same way. OAuth2ClientManagementController binds plain text in four places:

Where SQL
Create (insertEspi40ComplianceData) SET ... security_level = ?, client_status = ?
Update (updateEspi40ComplianceData) security_level = ? when security_level is given
List, status filter AND c.client_status = ?
List, securityLevel filter AND c.security_level = ?

So on PostgreSQL a client create fails after the client is saved, an update with security_level fails, and the list answers 500 when filtered by status or securityLevel. MySQL's ENUM accepts the text.

#350 fixed the same cause in the status update (ClientStatusService.statusParameterFor, CAST(? AS client_status_type) on PostgreSQL, the database read once at startup).

H2: the create's compliance update also writes espi_version, security_level, rate_limit_per_minute, max_concurrent_sessions and created_by, which the H2 schema does not have (H2 skipped V2, #145; #350's H2 V12 adds only client_status, locked_until and updated_by).

Fix

  • Cast each enum parameter on PostgreSQL, as the status update does (one helper per enum type, or a general enumParameterFor(type)).
  • Give H2 the columns the API writes, or write them only where they exist.
  • Run the client management create, update and list tests on PostgreSQL as well as MySQL (ClientSuspensionPostgreSqlIntegrationTest shows the pattern).

Activity

  1. dfcoffin commented on Nov 29, 2026

    @dfcoffin
    ContributorAuthor

    PR #350 (round-2 review fix) changes the list's status filter to the status in force (ClientStatusService.STATUS_IN_FORCE_SQL, a CASE whose result is text), so that filter now works on PostgreSQL and is tested there. Still open here: create's client_status / security_level, update's security_level, the list's securityLevel filter, and H2's create.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions