Skip to content

fix(server): handle PostgreSQL JSON values in character list#28

Merged
ailuckly merged 1 commit into
developfrom
fix/staging-character-pgobject
May 7, 2026
Merged

fix(server): handle PostgreSQL JSON values in character list#28
ailuckly merged 1 commit into
developfrom
fix/staging-character-pgobject

Conversation

@ailuckly
Copy link
Copy Markdown
Owner

@ailuckly ailuckly commented May 7, 2026

Summary

  • Fix /api/open/character/list returning 500 when pgjdbc returns PostgreSQL JSON/JSONB values as PGobject.
  • Convert map-backed string response fields through a safe helper instead of direct String casts.
  • Add a regression test covering PGobject tags from the public character list path.

Root Cause

The staging smoke request succeeded at SQL level, but CharacterOpenController.convertMapToResponse() cast tags directly to String. After the pgjdbc upgrade, the jsonb value was returned as org.postgresql.util.PGobject, causing ClassCastException and a 500 response.

Verification

  • mvn -Dmaven.repo.local=/tmp/juhao_m2repo -Dtest=CharacterOpenControllerTest test: passed.
  • ./scripts/validate-backend.sh: passed, 10 tests run.
  • git diff --check: passed.

Notes

  • This does not change the staging smoke script. The endpoint should return 200 instead of masking the failure.

Convert PGobject values from public character map queries before assigning string response fields.

This fixes staging validation returning 500 on /api/open/character/list after pgjdbc returns jsonb fields as PGobject.

Verification:

- mvn -Dmaven.repo.local=/tmp/juhao_m2repo -Dtest=CharacterOpenControllerTest test

- ./scripts/validate-backend.sh

- git diff --check
Copilot AI review requested due to automatic review settings May 7, 2026 00:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a backend 500 error on the public character list endpoint (/api/open/character/list) after a PostgreSQL JDBC behavior change where json/jsonb columns can be returned as org.postgresql.util.PGobject instead of String.

Changes:

  • Update CharacterOpenController.convertMapToResponse() to convert map-backed string fields via a safe helper (toStringValue) that unwraps PGobject.
  • Add a regression unit test ensuring PGobject JSONB values (e.g., tags) are converted into the expected JSON string output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
vocata-server/src/main/java/com/vocata/character/controller/CharacterOpenController.java Replace direct (String) casts with a helper that safely converts PGobject and other value types to String.
vocata-server/src/test/java/com/vocata/character/controller/CharacterOpenControllerTest.java Add a regression test that mocks a map record containing PGobject JSONB tags and asserts the endpoint returns 200 and correct tag string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ailuckly ailuckly merged commit 0554ce3 into develop May 7, 2026
9 checks passed
@ailuckly ailuckly deleted the fix/staging-character-pgobject branch May 7, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants