Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: fix assertion error serialization in exec() #393

Conversation

locker
Copy link
Member

@locker locker commented Oct 16, 2024

Commit e6a2093 ("Add error handling at the server instance") broke assertion failure reporting in server:exec() in case verbose error serialization is enabled in Tarantool (box_error_serialize_verbose compatibility option is set to new).

The problem is with the verbose error serialization, a raw string raised with error() is converted to an error object when marshalled through IPROTO while the server:exec() code expects it to remain a string because it encodes the original error in JSON. As a result, we get a mangled error like

{"status":"fail","class":"LuatestError","message":"...some_test.lua:42: expected: a value evaluating to true, actual: false"} {"code":32,"type":"LuajitError","trace":[{"file":"./src/lua/utils.c","line":687}]}

instead of

...some_test.lua:42: expected: a value evaluating to true, actual: false

To fix this issue, we revert the JSON encoding hack introduced by the aforementioned commit. In order not to reintroduce issue #242 fixed by that commit, we simply rollback the active transaction (if any) in case the executed function failed.

Closes #376

Commit e6a2093 ("Add error handling at the server instance") broke
assertion failure reporting in `server:exec()` in case verbose error
serialization is enabled in Tarantool (`box_error_serialize_verbose`
compatibility option is set to `new`).

The problem is with the verbose error serialization, a raw string raised
with `error()` is converted to an error object when marshalled through
IPROTO while the `server:exec()` code expects it to remain a string
because it encodes the original error in JSON. As a result, we get
a mangled error like

```
{"status":"fail","class":"LuatestError","message":"...some_test.lua:42: expected: a value evaluating to true, actual: false"} {"code":32,"type":"LuajitError","trace":[{"file":"./src/lua/utils.c","line":687}]}
```

instead of

```
...some_test.lua:42: expected: a value evaluating to true, actual: false
```

To fix this issue, we revert the JSON encoding hack introduced by the
aforementioned commit. In order not to reintroduce issue tarantool#242 fixed by
that commit, we simply rollback the active transaction (if any) in case
the executed function failed.

Closes tarantool#376
@locker locker force-pushed the fix-assertion-in-server-exec-with-verbose-error-serialization branch from c52aa69 to 0dabd85 Compare October 16, 2024 14:51
@locker locker requested a review from ylobankov October 16, 2024 15:06
@locker locker assigned Totktonada and unassigned ylobankov Oct 17, 2024
@Totktonada Totktonada removed their assignment Oct 17, 2024
@locker locker merged commit 3ad7fae into tarantool:master Oct 17, 2024
9 checks passed
@locker locker deleted the fix-assertion-in-server-exec-with-verbose-error-serialization branch October 17, 2024 15:22
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.

Unexpected information in luatest.assert_equals after enabling some compat options
3 participants