covid19cz/erouska-backend

GetCovidData: {"data": null } returns error

Closed this issue · 7 comments

{"data": null }

results in

{"error":{"code":3,"message":"Validation of the request has failed: validator: (nil)"}}%

but success is expected (as date is not mandatory)

@jendakol is it expected to return that error for {"data": null} from validation or is that a bug? https://github.com/covid19cz/erouska-backend/blob/develop/internal/utils/http/http.go#L93

I didn't think about it yet but... from the perspective you, in fact, don't fill in a required field, it makes sense, doesn't it? 🤔

I guess.
Btw for

{"data":{}}

it works as expected (ends up as successful request)

Seems good to me.
So to summarize:

  1. {} - invalid
  2. {"data": null} - invalid
  3. {"data": {}} - valid

Is it ok? I think it's both current and correct behavior.

IMHO having {"data": null} as valid input would be nice, but we are able to send {"data": {}} via Firebase SDK so it is not an issue for us anymore and can be closed.

thanks!