Skip to content

Handle invalid field errors in Mango#4709

Merged
nickva merged 1 commit intomainfrom
mango-handle-invalid-field-error
Jul 30, 2023
Merged

Handle invalid field errors in Mango#4709
nickva merged 1 commit intomainfrom
mango-handle-invalid-field-error

Conversation

@nickva
Copy link
Contributor

@nickva nickva commented Jul 29, 2023

Add handling for invalid field errors. Previously they would emit a 500 badmatch error with a stack trace:

% curl -v -XPOST -H'Content-type:application/json' $URL/db/_find -d '{"selector":{"_id":{"":null}}}'

< HTTP/1.1 500 Internal Server Error

{"error":"badmatch","reason":"{error,{{mango_error,mango_util,{invalid_field_name...

With the fix it emits a 400 error:

< HTTP/1.1 400 Bad Request

{"error":"invalid_field_name","reason":"Invalid field name: _id."}

This should also handle a general class of mango errors from $db/_find which are sent from the workers, passed through the fabric/rexi mechanism, and handled on the coordinator side. Previously some of those would emit the same 500 badmatch + a stack trace since we didn't expect errors in a few places which generated a badmatch.

@nickva nickva force-pushed the mango-handle-invalid-field-error branch from 17d8003 to dfbbe34 Compare July 29, 2023 07:00
{ok, FinalUserAcc1};
{ok, Error} when is_tuple(Error) ->
% fabric_view_all_docs turns {error, Resp} results into {ok, Resp}
% for some reason. If we didn't get a proper cursor record, assume
Copy link
Member

Choose a reason for hiding this comment

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

should we not fix that instead of papering over the odd behaviour? (he said without looking how hard that would be :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s been like that for years and it’s probably expected to return that in other places where all_docs is used. Since we don’t have rigorous tests for error conditions we’d probably break something else.

Add handling for invalid field errors. Previously they would emit a 500
`badmatch` error with a stack trace:

```
% curl -v -XPOST -H'Content-type:application/json' $URL/db/_find -d '{"selector":{"_id":{"":null}}}'

< HTTP/1.1 500 Internal Server Error

{"error":"badmatch","reason":"{error,{{mango_error,mango_util,{invalid_field_name...
```

With the fix it emits a 400 error:

```
< HTTP/1.1 400 Bad Request

{"error":"invalid_field_name","reason":"Invalid field name: _id."}
```

This should also handle a general class of mango errors from `$db/_find` which
are sent from the workers, passed through the fabric/rexi mechanism, and
handled on the coordinator side. Previously some of those would emit the same
500 badmatch + a stack trace since we didn't expect errors in a few places
which generated a `badmatch`.
@nickva nickva force-pushed the mango-handle-invalid-field-error branch from dfbbe34 to 0560b45 Compare July 29, 2023 13:04
@nickva nickva merged commit 64af302 into main Jul 30, 2023
@nickva nickva deleted the mango-handle-invalid-field-error branch July 30, 2023 16:15
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.

3 participants