Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Uncaught Error: Operation not permitted" should be catchable #852

Open
lgastako opened this issue Oct 15, 2016 · 3 comments
Open

"Uncaught Error: Operation not permitted" should be catchable #852

lgastako opened this issue Oct 15, 2016 · 3 comments

Comments

@lgastako
Copy link

lgastako commented Oct 15, 2016

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.

@magoomby
Copy link

magoomby commented Aug 5, 2017

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

@simonlc
Copy link

simonlc commented Aug 5, 2017

@magoomby That clearly does not solve his problem.

@lucienhetu
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants