Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

create_query_index() failing on unpartitioned CouchDB database with message invalid_partitioned_option #468

Closed
CodipherX opened this issue May 11, 2020 · 2 comments · Fixed by #470

Comments

@CodipherX
Copy link
Contributor

Please read these guidelines before opening an issue.

Bug Description

On trying to create query index in CouchDB 3.0.0, the request fails with an unpartitioned DB with message HTTPError: 400 Client Error: Bad Request invalid_partitioned_option

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Execute the following code

from cloudant import couchdb
from cloudant.design_document import DesignDocument

with couchdb("admin", "admin", url="http://127.0.0.1:5984") as couchClient:
        _ = couchClient.create_database("foo")
        
with couchdb("admin", "admin", url="http://127.0.0.1:5984") as couchClient:
    db = couchClient["foo"]
    ddoc = DesignDocument(db, document_id="bar")
    ddoc["language"] = "query"
    ddoc.save()

with couchdb("admin", "admin", url="http://127.0.0.1:5984") as couchClient:
    db = couchClient["foo"]
    db.create_query_index(design_document_id="_design/bar",fields=["key"])

2. What you expected to happen

The index should get created

3. What actually happened

Error is thrown with message - HTTPError: 400 Client Error: Bad Request invalid_partitioned_option Requested partitioned option does not match existing value on design document _design/bar for url: http://127.0.0.1:5984/foo/_index

Environment details

  • CouchDB - 3.0.0
  • Python 3.7
  • python-cloudant - 2.13

4. Workaround

In the cloudant/index.py, partitioned option was set only for partitioned = True. I added an else clause for partition = False and that fixed the issue.
Updating line 157-158 of cloudant/index.py

if self._partitioned:
  payload['partitioned'] = True
else:
  payload['partitioned'] = False
@bessbd
Copy link
Contributor

bessbd commented May 11, 2020

Hi @CodipherX ,

Thank you for reporting this issue! According to https://docs.couchdb.org/en/stable/api/database/find.html#post--db-_index , partitioned is not optional so this seems to be a python-cloudant bug.
I'll open a PR for this soon.

bessbd pushed a commit that referenced this issue May 12, 2020
`create_query_index` does not always supply `partitioned` which is
always required by the service.

This commit changes that so that `partitioned` is now always
present in the `create_query_index` requests.

This fixes #468
bessbd pushed a commit that referenced this issue May 12, 2020
`create_query_index` does not always supply `partitioned` which is
always required by the service.

This commit changes that so that `partitioned` is now always
present in the `create_query_index` requests.

This fixes #468
bessbd added a commit that referenced this issue May 14, 2020
`create_query_index` does not always supply `partitioned` which is
always required by the service.

This commit changes that so that `partitioned` is now always
present in the `create_query_index` requests when defined.

This fixes #468
@bessbd
Copy link
Contributor

bessbd commented May 14, 2020

Hi @CodipherX ,

I've just merged 14646b7 to master. Can you please verify that your issue is gone with that change?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants