Sync Gateway 403 Forbidden after PUT

My sync gateway is running using this config:

  "interface": ":4984",
  "adminInterface": ":4985",
  "log": [],
  "databases": {
    "db": {
      "bucket": "main",
      "server": "",
      "users": {
        "election-api": {
          "disabled": false,
          "admin_channels": ["db.election-api"]
      "sync": "function (doc, oldDoc) {\r\n   if ( doc.doc_type == \"election\" || doc.doc_type == \"contest\" || doc.doc_type == \"ballot\" ) {\r\n      channel(\"db.election-api\", doc.channels);\r\n   }\r\n}"

I am testing the sync gateway with some simple curl commands. First I create a doc using POST /db/

curl -i -X POST -H "Content-type: application/json" -d '{"doc_type": "election"}' ""

which gives:


Then I get all_docs as the election-api user to make sure I can see that doc (I got the token from admin port and /sessions endpoint):

curl -i --cookie "SyncGatewaySession=59c0d10091e9063ba33a73237a5c3a0467960c40" -H "Content-type: application/json" -X GET ""



Now I update the doc using a PUT:

curl -X PUT -H "Content-type: application/json" -d '{"newProp": "new"}' ""



The problem is that now when I run the same GET command from above ^^ I can’t see the document:


And if I try to find the doc by id using POST to _all_docs:

curl -i --cookie "SyncGatewaySession=59c0d10091e9063ba33a73237a5c3a0467960c40" -d '{"keys": [ "ac76656e7f25b7df215912d4648b3598" ]}' -H "Content-type: application/json" -X POST ""

I get 403 forbidden:


Please help. So confused. Thanks!

Updates to the doc aren’t incremental, so when you’re updating the doc, it’s setting the document body to {"newProp": "new"}. This doesn’t get assigned to any channels (as your sync function requires the doc_type property for channeling), so the user no longer has access to the doc.

Ahhhh and now its works. Thank you so much!