clients icon indicating copy to clipboard operation
clients copied to clipboard

Does `bw edit item` not allow changing the collection?

Open bemeyvif opened this issue 3 years ago • 6 comments

Describe the Bug

Trying to change the collectionIds to make an item belong to different collection(s).

Steps To Reproduce

# fe075cdc-04da-4489-be91-ad68008957e3 identifies an existing organization
# there's a valid `export BW_SESSION` defined

# creates a collection
echo '{"name": "collection_1", "organizationId": "fe075cdc-04da-4489-be91-ad68008957e3"}' | \
    base64 | \
    bw create org-collection --organizationid fe075cdc-04da-4489-be91-ad68008957e3
# returns 72af2365-352c-4d7f-8558-ae05017f95ba


# creates an item linked to the collection created just before
echo '{"collectionIds": ["72af2365-352c-4d7f-8558-ae05017f95ba"], "organizationId": "fe075cdc-04da-4489-be91-ad68008957e3", "folderId": null, "type": 1, "name": "title", "notes": null, "favorite": false, "login": {"username": "name", "password": "secret", "totp": null, "uris": []}, "fields": null, "secureNote": null, "card": null, "identity": null}' | \
    base64 | \
    bw create item
# returns 43015f22-7b00-45b2-bfe5-ae05017fd95b

# creates a new collection
echo '{"name": "collection_a", "organizationId": "fe075cdc-04da-4489-be91-ad68008957e3"}' | \
    base64 | \
    bw create org-collection --organizationid fe075cdc-04da-4489-be91-ad68008957e3
# returns 21de90df-ba46-43a0-868d-ae0501805be3

# trying to edit the item above with a different collectionIds value
echo '{"collectionIds": ["21de90df-ba46-43a0-868d-ae0501805be3"], "object": "item", "organizationId": "fe075cdc-04da-4489-be91-ad68008957e3", "folderId": null, "type": 1, "reprompt": 0, "name": "title", "notes": null, "favorite": false, "login": {"uris": [], "username": "name", "password": "secret", "totp": null, "passwordRevisionDate": null}}' | \
    base64 | \
    bw edit item 43015f22-7b00-45b2-bfe5-ae05017fd95b

# returns # {"object":"item","id":"43015f22-7b00-45b2-bfe5-ae05017fd95b","organizationId":"fe075cdc-04da-4489-be91-ad68008957e3","folderId":null,"type":1,"reprompt":0,"name":"title","notes":null,"favorite":false,"login":{"uris":[],"username":"name","password":"secret","totp":null,"passwordRevisionDate":null},"collectionIds":["72af2365-352c-4d7f-8558-ae05017f95ba","21de90df-ba46-43a0-868d-ae0501805be3"],"revisionDate":"2021-12-21T23:21:30.333Z"}

bw sync

Expected Result

Expected that the returned item would contain the new collection-id.

Actual Result

The returned json contains both the old and new collection-ids in the collectionIds. When using the web UI to look into the vault, the item still only part of the original collectionId.

Screenshots or Videos

NA

Environment

  • Operating system: Ubuntu
  • Shell: bash
  • Build Version (run bw --version): 1.19.1

Additional Context

NA

bemeyvif avatar Dec 21 '21 23:12 bemeyvif

I also tried to set collectionIds to [] and null. These do not remove the item from the collection when looking in the vault with the web UI. I also tried to make it part of both collections (e.g. ["72af2365-352c-4d7f-8558-ae05017f95ba", "21de90df-ba46-43a0-868d-ae0501805be3"]). The bw edit returns the item as being part of both collections. But the web UI does not reflect that change. Indeed a bw sync followed by a bw get item <item-id> still reports it is part of the only the first collection.

bemeyvif avatar Dec 22 '21 12:12 bemeyvif

Hi bemeyvif, We're cleaning up our repositories in preparation for a major reorganization. Issues from last year will be marked as stale and closed after two weeks. If you still need help, comment to let us know and we'll look into it. Thanks!

bitwarden-bot avatar Apr 12 '22 19:04 bitwarden-bot

@bitwarden-bot This issue of not being able to change a collection with bitwarden-cli is still present for me. It would be nice if someone could look into this ... I added steps to reproduce it easily ...

Is it up to me to remove the stale label?

aptly-io avatar Apr 25 '22 08:04 aptly-io

@dwbit @Hinton Is there any progress on this issue please? Thank you! Through the web client, it is possible to rename collections and change the association of an item with the available collections. So there must be some API to accomplish this. Maybe the code above should be done in some other way to change the collections that is associated with an item?

aptly-io avatar Jul 13 '22 19:07 aptly-io

Hello @aptly-io,

Thank you for reporting this and sorry for the late response! We were able to reproduce the issue on our end and a new bug was created in our internal bug-tracking system.

Hopefully this is going to be fixed soon!

federicom09 avatar Jul 18 '22 16:07 federicom09

Hello,

Can you share a status on this ?

Thanks!

pacrutchet avatar Feb 26 '24 19:02 pacrutchet

@Hinton is there any plan to include this to an upcoming release ?

pacrutchet avatar Apr 12 '24 17:04 pacrutchet

Hello everyone,

Could you please let me know if the example outlined here under "Or, to edit the collection(s) an item is in" assists with what you were attempting to accomplish?

Thank you in advance,

SergeantConfused avatar Aug 10 '24 12:08 SergeantConfused