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

Passing null parameters to replication.disable deletes the entire _replicator database #181

Closed
ColoradoFlyer opened this issue Sep 24, 2019 · 2 comments

Comments

@ColoradoFlyer
Copy link

ColoradoFlyer commented Sep 24, 2019

First, the documentation on github is incomplete; documentation for replication.disable does not show that _rev is required -- it is.

When attempting to delete a replication document, if _id and _rev are blank, Nano deletes the entire _replicator database.

For example:

// create a replication:
result = await local.db.replication.enable(local_logs, ${replURL}/${local_logs}, {
continuous: true,
_id: 'replicator::logs'
});

// delete the above replication
result = await local.db.replication.disable(result._id, result._rev);

This works just fine. Nano will issue a command similar to
DELETE /_replicator/replicator::logs?rev=1-afd307bf5728aa8e3ed6adf701f09678 HTTP/1.1

However, if for some reason the replication was not able to be created, result will not have an _id or _rev; and the command to delete the replication will cause Nano to issue the command

DELETE /_replicator HTTP/1.1

Which will happily destroy the _replicator database, causing any further replication actions to fail with "database does not exist".

Should there be a check on db.replication.disable to ensure that a document _id and _rev are passed in?

@sturdynut
Copy link

Thank you for posting this. Was unclear to me based on the example (below) that rev is required and would have been banging my head against a wall. I think the docs and example should be updated to note that rev is in fact required.

image

If there isn't any traction on this soon i'll PR the documentation update.

@glynnbird
Copy link
Contributor

As of Nano 8.2.0, mandatory parameters are enforced.

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

3 participants