Skip to content

Create and throw dedicated serialization exception. #274

@robsiera

Description

@robsiera

Sometimes Arango returns a Response that is marked as 'no-errors' but the result value is null.

Example:
When you call

PostCursorAsync<int>("RETURN MAX('Books'[*].Stock)")

and when there are no documents with a 'Stock' field, you get this response

{ "result": [null], "hasMore": false, "cached": false, "extra": { "stats": { "writesExecuted": 0, "writesIgnored": 0, "scannedFull": 0, "scannedIndex": 0, "filtered": 0, "httpRequests": 0, "executionTime": 3.802776336669922e-4, "peakMemoryUsage": 66480 }, "warnings": [] }, "error": false, "code": 201 }

This response will throw an error, as [null] cannot be deserialized to int.

So who is to blame?
Is this a Arango problem? Should a null result be marked as error?
What is the role of code 201 in this, if any? Is it relevant that we do not get a 200 code? If so, shouldn't the client handle this relevant information?
If [null] is a valid answer, then why does the client try to deserializing it.

I would love to hear your thoughts, before I try create a PR.

Personally, I think Arango is in the wrong. The return value of a MAX operation is an INT. If Arango thinks that a value of ZERO is not appropriate in this case (which is a valid point of view) then that should result in an error or at least a warning.

EDIT
Or am I wrong to call this query with PostCursorAsync in the first place?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions