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

Difficult to debug tests with db methods due to masked error messages

Open finestructure opened this issue 1 year ago • 1 comments

I have a number of db related unit tests that started failing due to recent changes and I find it very difficult to debug them due to the masked error messages:

2024-07-03T11:56:40+0200 debug codes.vapor.application : component=server database-id=psql psql_connection_id=2 psql_error=PSQLError – Generic description to prevent accidental leakage of sensitive data. For debugging details, use `String(reflecting: error)`. [PostgresNIO] Cleaning up and closing connection.

I understand the reason for this but there really should be an opt-out I can set in unit tests, because the recommended way of dealing with these errors is not actually actionable.

The errors are thrown and handled somewhere in the stack and a priori I don't know where, so I can't just go in and add a do { } catch { String(reflecting: error) } (leaving aside that that by itself would also be quite tedious) without a lot of digging.

Or is there a way to make this possible that I'm not aware of?

It would be great to have some means to get back to the previous, "leaky" error messages even if they're not the default.

finestructure avatar Jul 03 '24 10:07 finestructure

I've hit this problem as well today. This makes it impossible to understand why a test is failing, and re-writing all tests to print the error is not a viable workaround.

I suggest adding an opt-out flag, and consider automatically disabling this feature when building in DEBUG mode.

arroz avatar May 16 '25 15:05 arroz