-
Notifications
You must be signed in to change notification settings - Fork 2
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
Non-SelfDescribingErrors mode: add new wire types for "ERROR" and "PATH" #1
Comments
Thanks for opening this issue Andrew! Here are a few initial thoughts on A-E, as well as a new thought F: (A) Error type as DESCThe difference in size seems ok to me for traditional request/response workflows, but I do understand that DESC is a bit annoying and unsatisfying, and that we're building up to stream/defer use cases, so I'll leave this one alone. (B) Error type as RECORD with STRING[] pathThe upshot here is relative simplicity, relatively easy debuggability, and easy pairing with BLOCK-deduping for path elements (which seems likely to help quite a bit in stream/defer). The downside is in practice, the string paths could be large-ish---certainly they might dominate the payload size, but in these cases the total payloads are small (say, hundreds of bytes). (C) Error type as RECORD with PATH pathNot a bad idea. It introduces an Argo-native concept to the strange path encodings demanded by the GraphQL spec, which might be helpful. The use of 0 is clever and seems unlikely to be a real problem, but it does muddy up the meaning of Labels just a bit, and it introduces a new concept to Argo (basically, tagged unions). (D) Error type as ERRORThere might be some upshot in having names for common types, but I think it's preferable to achieve this without introducing new kinds of Wire types--this way, code that handles wire Types doesn't need to know about ERROR specifically. Contrasting with PATH, the case seems less strong for introducing a first-class concept/type. (E) Field errors encoding (not yet implemented)Yeah, this is described in 5.8.3 Field errors, and you need a partial path to know where the errors bubbled up from (if originating in a nested non-nullable field). However, I expect the space saving is unimportant for most traditional request/response use cases, and it seems somewhat unlikely to be possible in stream/defer. I think that means the approaches other than E are more worth looking into. You make a good point about multiple errors, I should look into whether it ought to be an inline array of error values. (F) Error type as
|
I like (F), I think it has much better potential for savings compared to (B) and (C). I think (E) is most useful for codegen purposes, but otherwise I agree that having it as its own wire type doesn't provide anything new. I'll put together another issue soon-ish with more details about defer/stream, which is where I'm hoping the optimized PATH type (F) will be more useful. |
TL;DR: I'm proposing that Argo add a
PATH
wire type and anERROR
wire type. See examples (C) and (D) below.Why?
The current reference implementation of Argo only supports
SelfDescribingErrors
andOutOfBandFieldErrors
.The purpose of this issue is to explore and discuss what non-self-describing errors might look like in their encoded form and whether having additional wire types for
PATH
andERROR
would be beneficial.All of the examples below use the following JSON value as an example GraphQL response:
The original GraphQL query isn't important, but it could be imagined to look like this:
(A) Error type as
DESC
Reference implementation wire type (using
DESC
for the Error type):Encoding with
InlineEverything
,OutOfBandFieldErrors
, andSelfDescribingErrors
enabled:(B) Error type as
RECORD
withSTRING[]
pathGenerally follows section 5.8.1 from the Argo 1.0.0 spec:
Encoding with
InlineEverything
andOutOfBandFieldErrors
enabled:(C) Error type as
RECORD
withPATH
pathNew proposed
PATH
type instead ofSTRING[]
:Encoding with
InlineEverything
andOutOfBandFieldErrors
enabled:The main difference here being that path segments may only be one of the following:
It's expected that most path segments will be a non-empty String for a field name or alias, so by enforcing that the length of a
FieldName
segment is non-zero, we can use theNON_NULL
label (which is0
) as a reserved label to indicate that aVARINT
for aListIndex
is expected next instead of a String.So, using the example from (B), the zero
0
path segment encoding from["b", 0, "x", "y"]
would normally encode as a String:With the
PATH
type, it would be encoded as follows:Where the first
Varint()
refers to the labelNON_NULL
.For single field errors, the difference between
PATH
andSTRING[]
is negligible and should normally result in same-size or slightly smaller encodings compared to theSTRING[]
variant (cases where aListIndex
with an integer value larger than 9 would result in a smaller encoding).More benefits from
PATH
will be described in more detail in a future issue related to@defer
and@stream
support, which heavily relies on thePATH
type.(D) Error type as
ERROR
New proposed
ERROR
type, which is identical to (C) above, but can be re-used wherever the Error type may need to be used:Encoding with
InlineEverything
andOutOfBandFieldErrors
enabled:TODO: (E) Field errors encoding (not yet implemented)
For non-
OutOfBandFieldErrors
mode, theERROR
label could be written to an otherwisenull
field and immediately be followed by a list(?) ofERROR[]
.I don't think the GraphQL specification limits how many errors might be returned for a particular
path
, so I'm assuming Argo would need to support a list of field errors.It might be possible to drop the
path
field when encoded as a field error. This is assuming that thepath
could be reconstructed by walking the decoded field itself in combination with the given wire type. For field errors involving arrays, this might work, but for incremental updates it's unclear whetherpath
may be omitted or not.The text was updated successfully, but these errors were encountered: