dd66327b

Created Started Finished

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Decode Prometheus's answer with a codec

It was JSON.decode and a walk down the KeyMap, which is the same mistake one
layer out that this library exists to stop: the shape of the response written
as a sequence of lookups, with every step that could go wrong answered by a
guess.  The response is a discriminated union on status, so it is written as
one.

Two things fall out of that.

A response that is neither answer now throws rather than coming back as
Unparseable.  It is not a refusal: a refusal is Prometheus saying what is
wrong with the query, and a test told that would go looking at the query when
the thing to look at is the server.

And the refusal half of the envelope is now read by something.  Every property
in the suite asserts that Prometheus parsed what it was given, so none of them
ever sees one, and a wrong discriminator would have turned every rejected
query into an exception with nothing to say.  There is a test for it now.