PUT aborted by pre-commit hook

Sebastian Schmidt sebi at sebisworld.com
Wed Mar 7 20:28:59 EST 2012

I am just starting out with Riak and want to use Pre-Commit Hooks to
automatically add links to keys in a different bucket. To give a
simple example, when I add '/bucket2/object2' I want to add a link to
the object in '/bucket1/object1' that points to the new object. I
would like to do this in javascript and would appreciate if someone
could help me get started. I could not find a single working example,
and have had difficulties in even getting the basics up and running.

What I have done so far is:

- Changed the js_source_dir directory to './js_source'
- In js_source, I added a file 'validate.js':

var validateFunctions = {
  validate: function(v) {
     return v;

module.exports = {'name': validateFunctions }

- I created a new bucket as such:

curl -v -X PUT -H "Content-Type: application/json" -d '{"props":
{"precommit": [{"name": "validate"}]}}'

- I added a new key to this bucket:

curl -v -X PUT -d '{"bar":"baz"}' -H "Content-Type: application/json"
 -H "X-Riak-Vclock: a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA=="

This results in a 403 "PUT aborted by pre-commit hook" failure.

Aside from the obvious "how do I get it to work?" question, I would like to know
1) if there is a working example on the web or a tutorial that shows
all the required steps (the Basho Commit Hooks tutorial does not
actually show how to enable these hooks)
2) if I need to do anything when I change my Javascript files (restart
server, re-initialize my buckets, ..)
3) if there is a naming convention that I need to follow for my *.js files
4) how to process links in Javascript

So far, I have a a great experience getting to know Riak, but the
limited documentation really hinders my progress :)


More information about the riak-users mailing list