stackvana / hook.io

Open-Source Microservice Hosting Platform
https://hook.io
Other
1.26k stars 117 forks source link

Regression on datastore promises #235

Closed monkbroc closed 8 years ago

monkbroc commented 8 years ago

This code no longer works because hook.datastore.get() doesn't return a Promise anymore.

module['exports'] = function (hook) {
  hook.datastore.get('key')
  .then(function (value) {
    hook.res.end("Value " + value);
  });
};
Marak commented 8 years ago

Try again?

monkbroc commented 8 years ago

hook.datastore.get(), set(), del(), exists(), recent() used to return a Promise https://github.com/bigcompany/hook.io-datastore/pull/1

It appears that it no longer does, breaking code that relied on the Promise API of hook.datastore

Marak commented 8 years ago

Can you try again?

monkbroc commented 8 years ago

It's a different error now. No longer a function call error on then() but this.

 {"error":true,"message":"\"anonymous\" does not have the role \"datastore::get\" which is required to access \"/datastore/get\"\n\nIf you are the owner of this resource try logging in at https://hook.io/login\n\nIf any access keys have been created you can also provide a `hook_private_key` parameter to access the service.","user":"anonymous","role":"datastore::get","type":"unauthorized-role-access"}
Marak commented 8 years ago

Try one more time. We had some issues migrating legacy users.

monkbroc commented 8 years ago

Thanks. It is working again now. That's an strange manifestation of a migration issue, but thanks for resolving it quickly!

Marak commented 8 years ago

Is quite simple.

First, https://github.com/bigcompany/hook.io-sdk/blob/master/index.js#L63 was not set in chroot jail. So that is one line change.

Second, your user document was cached and missing new internal API access key. I cleared cache and your new internal api access key is now bound to your user scope.

Sorry for the issues!