Skip to content

Streaming JSON API: Make error behavior consistent and document it #4521

Closed
@hurryabit

Description

To be honest, I don't fully understand the current error behavior. Here's something I've observed:

  1. When I send a request that is syntactically wrong, I get the message
    {"error":"Endpoints.InvalidUserInput: JsonReaderError. Cannot read JSON: <{}>. Cause: spray.json.DeserializationException: Object is missing required member 'templateIds'"}
    and the stream carries on. I would expect the stream to be closed since there'll never be any events.
  2. When I send a request with an empty list of template ids, I get the message
    {"error":"Endpoints.InvalidUserInput: JsonReaderError. Cannot read JSON: <{\\"templateIds\\":[]}>. Cause: spray.json.DeserializationException: search requires at least one item in 'templateIds'"}
    and the stream carries on. Again, I would expect the stream to be closed.
  3. When I send a request with one template id that is bogus, I get a message like
    {"error":"Cannot resolve any templateId from request: GetActiveContractsRequest(Set(TemplateId(Some(bbbbfec7d278f3ac692e82fa94f1f4a322576abe043cdb7b490c67d1e10214d2),DAVL,EmployeeProposalX)),Map()), unresolved templateIds: Set(TemplateId(Some(bbbbfec7d278f3ac692e82fa94f1f4a322576abe043cdb7b490c67d1e10214d2),DAVL,EmployeeProposalX))"}
    and the stream carries on. I would expect the stream to be closed again.
  4. When I send a second request on a connection, it gets silently dropped on the floor.

I have a few thoughts about this:

  1. For the sake of consistency with other endpoints, it would make sense to change error message to a format like {"errors": [...]}?
  2. Whenever the list of valid queries is empty or the query is completely bogus, shouldn't we close the stream immediately?
  3. Would it make sense to send warnings for all template ids that cannot be resolved and send an error if the list of template ids that can be resolved is empty? Thus, a query containing only invalid template ids would first have a warning for each template id that it cannot be resolved and then an error that there are no template ids that can be resolved. Sending an empty list of template ids would not trigger the warning but only the error.
  4. We should send an error message for each request that gets sent after the first request.

Whatever we agree on, we need better documentation for this. Currently, I can't find any mention of error messages on the streaming endpoints at all.

Metadata

Labels

component/json-apiHTTP JSON APIdiscussionThings to be discussed and decidedteam/ledger-clientsRelated to the Ledger Clients team's components.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions