postgres-nio icon indicating copy to clipboard operation
postgres-nio copied to clipboard

When loading data type as jsonb, an extra unicode will be added: \u0001

Open iwecon opened this issue 5 months ago • 5 comments

Describe the issue

loading data type as jsonb, an extra unicode will be added: \u0001 (show in json result) or \u{01} (show in Xcode)

Vapor version

1.26.2

Operating system and version

macOS 26 DP Beta 1 and Ubuntu Linux 22.04

Swift version

macOS: 6.1.2, Ubuntu: swift-6.1.0-release

Steps to reproduce

  1. Upgrade all packages to latest version;
  2. Connect PostgreSQL and query a type as jsonb field;
  3. the result ByteBuffer decode to String.self, an additional \u{01} will be displayed (in Xcode Console); return it as json to response, it will show \u0001 (additional)
  • in Xcode Console Image

  • in Postman response raw Image

  • in DB (it is correct) Image

Additional notes

When I downgraded back to 1.24.0, everything worked fine!!

If more information is needed, please let me know

iwecon avatar Jun 11 '25 21:06 iwecon

@natebird @rgcottrell @ts @shnhrrsn please check it!

iwecon avatar Jun 11 '25 21:06 iwecon

@iWECon good catch. Postgres signals jsonb with this extra character. Would you be interested in proposing a PR that fixes this issue?

When I downgraded back to 1.24.0, everything worked fine!!

Oh that sounds weird. I don't think we changed anything in there. But let me recheck.

fabianfett avatar Jun 12 '25 05:06 fabianfett

@iWECon good catch. Postgres signals jsonb with this extra character. Would you be interested in proposing a PR that fixes this issue?

When I downgraded back to 1.24.0, everything worked fine!!

Oh that sounds weird. I don't think we changed anything in there. But let me recheck.

Yes, I have checked versions 1.26.2 to 1.24.0, and I have not found any related codes.

In addition, the versions written above are all postgres-nio versions, and vapor is the latest version.

iwecon avatar Jun 12 '25 05:06 iwecon

I believe this was introduced in https://github.com/vapor/postgres-nio/pull/548 - I'm also seeing something similar with it working on 1.25.0 but breaking in 1.26.0

0xTim avatar Jun 16 '25 00:06 0xTim

@0xTim Good point, but how has json -> String worked before #548?

fabianfett avatar Jun 16 '25 05:06 fabianfett

@fabianfett I have no idea, I'm assuming it was falling back to something on a path that's now missed? But it definitely worked - one project I'm on has pinned to 1.25.0 to work around. Want a PR?

0xTim avatar Jun 20 '25 15:06 0xTim

yes, I'm happy to accept such a pr. with test case, please :)

fabianfett avatar Jun 20 '25 16:06 fabianfett