rethinkdb/horizon

"Uncaught Error: Operation not permitted" should be catchable

Opened this issue · 3 comments

Server version: 2.0.0-beta-7
Client version: 2.0.0-beta-7

I am executing a query like this:

try {
    log("saving...");
    (hz("table")
     .store(record)
     .subscribe(function success(result) {
         log("ok => "+ show(result));
         // ... use result here ....
     }, function failure(err) {
         log("err => " + show(err));
         // ... handle error here ...
     }));
} catch (ex) {
    log("boom - error saving record");
    console.error(ex);
}

And I see "saving..." but then no "ok", "err", or "boom" and then get this error uncaught at the top level:

Uncaught Error: Operation not permitted.
     next @ ast.js:283
     e.__tryOrUnsub @ Subscriber.js:223
     e.next @ Subscriber.js:172
     e._next @ Subscriber.js:125
     e.next @ Subscriber.js:89
     e.nextOrComplete @ takeWhile.js:84
     e._next @ takeWhile.js:79
     e.next @ Subscriber.js:89
     e._next @ Subscriber.js:125
     e.next @ Subscriber.js:89
     e.next @ Subject.js:55
     e._next @ Subscriber.js:125
     e.next @ Subscriber.js:89
     e.notifyNext @ mergeMap.js:133
     e._next @ InnerSubscriber.js:23
     e.next @ Subscriber.js:89
     u @ subscribeToResult.js:26
     e._innerSub @ mergeMap.js:120
     e._tryNext @ mergeMap.js:117
     e._next @ mergeMap.js:100
     e.next @ Subscriber.js:89
     e.notifyNext @ OuterSubscriber.js:19
     e._next @ InnerSubscriber.js:23
     e.next @ Subscriber.js:89
     (anonymous function) @ WebSocketSubject.js:79
     e.__tryOrUnsub @ Subscriber.js:223
     e.next @ Subscriber.js:172
     e._next @ Subscriber.js:125
     e.next @ Subscriber.js:89
     e.next @ Subject.js:55
     r.onmessage @ WebSocketSubject.js:160

NB. None of that is code that is in my control.

I would expect this to come back in the failure branch of the subscription, or at the very least be able to be handled somehow. The Operation not permitted error is correct -- the thing I am testing that is causing this error is trying to create to items with the same primary key -- it's correctly failing the second one but I of course want to be able to handle this and gracefully report to the user that the key is already taken.

launch with permission checking off in dev. hz serve --dev --permissions no

@magoomby That clearly does not solve his problem.

it looks like an entry is missing under schema.toml, smtg like :

[groups.authenticated.rules.write_to_table]
template = "collection('table').store(any())"