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

api: support errors extended information and error type in MessagePack #229

Merged
merged 4 commits into from
Dec 7, 2022

Conversation

DifferentialOrange
Copy link
Member

@DifferentialOrange DifferentialOrange commented Nov 16, 2022

Merge after #226

code health: rename error iproto code

Since 2.4.1 IPROTO_ERROR (0x31) is renamed to IPROTO_ERROR_24 and IPROTO_ERROR name is used for 0x52 constant describing extended error info [1].

  1. https://www.tarantool.io/en/doc/latest/dev_guide/internals/msgpack_extensions/#the-error-type

Part of #209

api: support errors extended information

Since Tarantool 2.4.1, iproto error responses contain extended info with backtrace [1]. After this patch, Error would contain ExtendedInfo field (BoxError object), if it was provided. Error() handle now will print extended info, if possible.

  1. https://www.tarantool.io/en/doc/latest/dev_guide/internals/box_protocol/#responses-for-errors

Part of #209

api: support error type in MessagePack

Tarantool supports error extension type since version 2.4.1 [1], encoding was introduced in Tarantool 2.10.0 [2]. This patch introduces the support of Tarantool error extension type in msgpack decoders and encoders.

Tarantool error extension type objects are decoded to *tarantool.BoxError type. *tarantool.BoxError may be encoded top Tarantool error extension type objects.

Error extension type internals are the same as errors extended information: the only difference is that extra information is encoded as a separate error dictionary field and error extension type objects are encoded as MessagePack extension type objects.

The only way to receive an error extension type object from Tarantool is to receive an explicitly built box.error object: either from
return box.error.new(...) or a tuple with it. All errors raised within Tarantool (including those raised with box.error(...)) are encoded based on the same rules as simple errors due to backward compatibility.

It is possible to create error extension type objects with Go code, but it not likely to be really useful since most of their fields is
computed on error initialization on the server side (even for custom error types).

This patch also adds ErrorExtensionFeature flag to client protocol features list. Without this flag, all box.error object sent over
iproto are encoded to string. We behave like Tarantool net.box here: if we support the feature, we provide the feature flag.

Since it may become too complicated to enable/disable feature flag through import, error extension type is available as a part of the base package, in contrary to Decimal, UUID, Datetime and Interval types which are enabled by importing underscore subpackage.

  1. Expose box.error to be used by applications tarantool#4398
  2. Enable encoding errors as MP_ERROR msgpack extension tarantool#6433

Closes #209

I didn't forget about:

@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-120-iproto-id branch 2 times, most recently from 39e6c7e to 4dde607 Compare November 17, 2022 09:47
@DifferentialOrange DifferentialOrange changed the title Differential orange/gh 209 error type Error type Nov 17, 2022
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-120-iproto-id branch 23 times, most recently from d1f025b to 596820a Compare November 21, 2022 09:49
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch from 9ae0e98 to a49bcd3 Compare November 21, 2022 12:31
box_error.go Outdated Show resolved Hide resolved
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch 2 times, most recently from c0d28bc to 0d431a6 Compare November 23, 2022 12:46
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-120-iproto-id branch 2 times, most recently from 33d0483 to 999cf4a Compare November 30, 2022 07:34
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch from 08ff8fe to e06592f Compare November 30, 2022 07:35
Base automatically changed from DifferentialOrange/gh-120-iproto-id to master November 30, 2022 08:33
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Let's do rebase to master.

@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch from e06592f to 87fe913 Compare December 1, 2022 08:56
box_error.go Outdated Show resolved Hide resolved
box_error.go Outdated Show resolved Hide resolved
box_error.go Outdated Show resolved Hide resolved
box_error_test.go Outdated Show resolved Hide resolved
const.go Outdated Show resolved Hide resolved
errors.go Show resolved Hide resolved
tarantool_test.go Show resolved Hide resolved
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch 3 times, most recently from cbd40c2 to e6c5a3f Compare December 1, 2022 12:08
const.go Outdated Show resolved Hide resolved
test_helpers/utils.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thanks for the patch! I finally checked all dots at the ends of the comments. =)
There are just a couple of non-critical conversations to resolve.

@oleg-jukovec oleg-jukovec requested a review from AnaNek December 1, 2022 13:02
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch 2 times, most recently from 0ee60e3 to ae90ad5 Compare December 1, 2022 13:44
Copy link

@AnaNek AnaNek left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

You could also cherry-pick the commit:
8cb6489

CHANGELOG.md Outdated Show resolved Hide resolved
oleg-jukovec and others added 4 commits December 6, 2022 16:41
Since 2.4.1 IPROTO_ERROR (0x31) is renamed to IPROTO_ERROR_24 and
IPROTO_ERROR name is used for 0x52 constant describing extended error
info [1].

1. https://www.tarantool.io/en/doc/latest/dev_guide/internals/msgpack_extensions/#the-error-type

Part of #209
Since Tarantool 2.4.1, iproto error responses contain extended info with
backtrace [1]. After this patch, Error would contain ExtendedInfo field
(BoxError object), if it was provided. Error() handle now will print
extended info, if possible.

1. https://www.tarantool.io/en/doc/latest/dev_guide/internals/box_protocol/#responses-for-errors

Part of #209
Tarantool supports error extension type since version 2.4.1 [1],
encoding was introduced in Tarantool 2.10.0 [2]. This patch introduces
the support of Tarantool error extension type in msgpack decoders and
encoders.

Tarantool error extension type objects are decoded to
`*tarantool.BoxError` type. `*tarantool.BoxError` may be encoded to
Tarantool error extension type objects.

Error extension type internals are the same as errors extended
information: the only difference is that extra information is encoded as
a separate error dictionary field and error extension type objects are
encoded as MessagePack extension type objects.

The only way to receive an error extension type object from Tarantool is
to receive an explicitly built `box.error` object: either from
`return box.error.new(...)` or a tuple with it. All errors raised within
Tarantool (including those raised with `box.error(...)`) are encoded
based on the same rules as simple errors due to backward compatibility.

It is possible to create error extension type objects with Go code,
but it not likely to be really useful since most of their fields is
computed on error initialization on the server side (even for custom
error types).

This patch also adds ErrorExtensionFeature flag to client protocol
features list. Without this flag, all `box.error` object sent over
iproto are encoded to string. We behave like Tarantool `net.box` here:
if we support the feature, we provide the feature flag.

Since it may become too complicated to enable/disable feature flag
through import, error extension type is available as a part of the base
package, in contrary to Decimal, UUID, Datetime and Interval types which
are enabled by importing underscore subpackage.

1. tarantool/tarantool#4398
2. tarantool/tarantool#6433

Closes #209
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-209-error-type branch from ae90ad5 to 11970e1 Compare December 6, 2022 13:42
@DifferentialOrange
Copy link
Member Author

You could also cherry-pick the commit: 8cb6489

Cherry-picked.

What's about tarantool/setup-tarantool#37 ?

@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Dec 6, 2022

What's about tarantool/setup-tarantool#37 ?

To be honest, I wasn't looking for a solution yet (quickfix ubuntu-latest -> ubuntu-22.04 does not help). You could fix it if you want, or just ignore it.

@oleg-jukovec oleg-jukovec merged commit 319c93b into master Dec 7, 2022
@oleg-jukovec oleg-jukovec deleted the DifferentialOrange/gh-209-error-type branch December 7, 2022 07:31
@DifferentialOrange
Copy link
Member Author

quickfix ubuntu-latest -> ubuntu-22.04

Quickfix is ubuntu-latest -> ubuntu-20.04

@oleg-jukovec
Copy link
Collaborator

quickfix ubuntu-latest -> ubuntu-22.04

Quickfix is ubuntu-latest -> ubuntu-20.04

Thank you, it works:

cc03989

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.

Support the ERROR type
3 participants