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

Write with Overwrite = true fails if doc doesn't exist #112

Open
tleyden opened this issue Jul 6, 2017 · 2 comments
Open

Write with Overwrite = true fails if doc doesn't exist #112

tleyden opened this issue Jul 6, 2017 · 2 comments

Comments

@tleyden
Copy link

tleyden commented Jul 6, 2017

If you do a write with --param overwrite 'true' on a non-existent doc id:

wsk action invoke cloudant/write --blocking --result --param overwrite 'true' --param doc '{"foo": "bar", "_id": "nonexistent_docid"}'

it gives an error:

        "stack": "Error: missing\n    at Request._callback (/nodejsAction/node_modules/cloudant-nano/lib/nano.js:247:15)\n    at Request.self.callback (/nodejsAction/node_modules/request/request.js:186:22)\n    at emitTwo (events.js:106:13)\n    at Request.emit (events.js:191:7)\n    at Request.<anonymous> (/nodejsAction/node_modules/request/request.js:1081:10)\n    at emitOne (events.js:96:13)\n    at Request.emit (events.js:188:7)\n    at IncomingMessage.<anonymous> (/nodejsAction/node_modules/request/request.js:1001:12)\n    at IncomingMessage.g (events.js:291:16)",
        "statusCode": 404

But if I remove the --param overwrite 'true', it works. And then subsequent writes with --param overwrite 'true' succeed and update the revision.

In this case, I think it's safe to ignore the 404 error trying to do the GET to fetch the existing revision, since it's expected that it might be the first revision, and no existing revisions exist.

@daisy-ycguo
Copy link
Member

#110 is a related issue.

@tleyden
Copy link
Author

tleyden commented Jul 6, 2017

Here's a rough golang version that works as I would expect in terms of writing a new doc or overwriting an existing doc

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

2 participants