FriendsOfOuro / geteventstore-php-core

PHP Client for Event Store HTTP API

Home Page:http://friendsofouro.github.io/geteventstore-php-core/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fatal error when trying to open a stream

Akii opened this issue · comments

commented

For whatever reason, eventstore sends a 401 for any internal projection (e. g. $ce-things). EventStore::ensureStatusCodeIsGood only checks for 404 and 410.

GET: http://127.0.0.1:2113/streams/$et-asdf -> 401
GET: http://127.0.0.1:2113/streams/et-asdf -> 404

In my opinion, anything that's not 2xx should be considered a failure.

The concrete error:

Catchable Fatal Error: Argument 1 passed to
  EventStore\StreamFeed\StreamFeed::__construct() must be of the type
  array, null given, called in
  [...] EventStore.php
  on line 207

I would prefer to be explicit in status code mapping, what other codes may happen?
e.g. 403

commented

Any code may happen. At the moment, those three are the only ones I encountered. I'm all for making things explicit but in this case the RFC has defined those codes, thus making them available to the eventstore to use at any time.

@nicolopignatelli any suggestion about exception name?

we can easily map the status codes we know about, then fallback on a generic error if the status code is not 2xx

commented

+1

I already answered this on twitter but this is not a bug.

$streams (internal streams) require admin access by default (this can be changed by changing the default ACL). See default ACLs http://docs.geteventstore.com/server/3.1.0-pre/access-control-lists/

If you do not send credentials a 401 is quite a reasonable status code to send.

Note that it will send a 401 for any $ prefixed stream without a user.

commented

Thanks for clarifying again. After thinking more about it, it absolutely makes sense.

commented

This should be fixed in master.