Open VdeVentura opened 2 months ago
What language are you using on the client? Are you using embedded replicas or remote only? What is the exact problem with error handling? It seems that proxy error includes all the details of the problem, no?
I'm using TS with Prisma, I could very well just assume that "PROXY_ERROR" is the same as a constraint violation, but it's highly unexpected considering that statement errors in libsql contain a SqliteError
which is mapped to sqlite_error_code
and the latter contains SQLITE_CONSTRAINT
This is because the statement was proxied to the primary. We need to improve how errors are reported back to the replica, and then returned to the client.
@MarinPostma: confirmed, I deleted the replica and started getting the expected error codes, however, I think there might still be something funky going on (it might even be on prisma's side, but from a high level look at the code, it sounds like it could be on libsql):
now I'm getting SQLITE_CONSTRAINT
, which I can work with, but prisma is not supposed to return the libsql code; it's supposed to map it to their internal error codes (unique constraint for example). Looking at the specificity of the errors that prisma is intended to report, it looks difficult to map something as generic as SQLITE_CONSTRAINT
to Unique constraint
or Null constraint
for example.
Seems that prisma is expecting something along the lines of SQLITE_CONSTRAINT_UNIQUE
or SQLITE_CONSTRAINT_NOTNULL
which would be even better for error handling than just SQLITE_CONSTRAINT
As mentioned in the title, following are 2 traces coming from turso's UI, it's very easy to reproduce:
Violating NOT NULL constraint
Violating UNIQUE constraint
This is a problem as it hurts error handling in apps.