How to know programmatically the reason why an user-defined projection has faulted?


When creating an user-defined projection through the API, whether or not the submitted

query was valid, the server will return a 201 HTTP status followed by a JSON object

comprised of a message-type id (value 257) and the name of the created projection.

When submitting a malformed query (like invalid javascript or use of non-existing function), The only way

to get the failure’s message is to go straight to ‘Projections’ panel, underneath the projection’s name.

However, I’d like to retrieve that message programmatically. So far I was able to retrieve that message

by reading $projections-$master stream. In that stream, I can spot an event with the type $faulted that

hold the information I need: “TypeError: fromCategory.when is not a function”.

The problem is I don’t see how to correlate that event to my projection because, the id property within

the JSON payload doesn’t correspond to any projection info I’m aware of: “d22e99329b144074b208eb69d0f18367”.

My guess would be this to be some kind of SHA1 of something related to the projection.

Could someone shed some light on this, please?

Thank you for your time.


After reading EventStore codebase, that Id is the internal projection id, a generated Guid used to store the managed projection in a dictionary.

I misread the code, that projection-id is the event-number resulting from writing the registration of the projection in $projections-$all stream.

To achieve what I need, it seems all I have to do is the retrieve the first event in $projections-$all stream, with the type $ProjectionCreated with a matching name in its payload. By looking at the code in
ProjectionManager, the projection’s name is just UTF-8 encoded with Helper.UTF8NoBom.GetBytes.

Could someone confirm this?

Turns out I can have the information I need by looking at GET /projection/{name}. Somehow I didn’t see it the first time I tried the query.
Sorry for the noise. Good news is I had the chance to read the projection code :-] !