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

Unable to update a subset of item attributes #61

Open
mega-nick opened this issue Mar 1, 2023 · 1 comment
Open

Unable to update a subset of item attributes #61

mega-nick opened this issue Mar 1, 2023 · 1 comment

Comments

@mega-nick
Copy link

Your environment

Chart Version: 1.10.0
Helm Version: 3.11.1
Kubernetes Version: v1.24.9
Docker Compose: v2.15.1

What happened?

I used PATCH /v1/vaults/{vaultUUID}/items/{itemUUID} as found in the API reference but got a 400 response code when using the 1Password connect server deployed via both the Docker Compose example and the connect server Helm chart with Minikube.

I've ran curl -i -X PATCH $OP_CONNECT_HOST/v1/vaults/$OP_VAULT/items/$OP_ITEM_ID -H "Content-Type: application\json" -H "Authorization: Bearer $OP_CONNECT_TOKEN" -d "{ "op":"replace", "path":"/title", "value":"hello-world" }" against both deployments which returned a 400. I've also tried this with different paths like title, /fields/username, /fields/username/label which have all returned 400 as well.

On both deployments of the 1Password Connect server I was successfully able get and delete items from the vault which makes me think the token in use is fine.

What did you expect to happen?

I expected to update part of the 1Password item.

Steps to reproduce

  1. Setup 1Password connect server using either Helm or Docker Compose
  2. Replace a subset of a 1Password item attributes using PATCH /v1/vaults/{vaultUUID}/items/{itemUUID}

Notes & Logs

Vault ID and Item ID have been replaced with X

compose-op-connect-api-1   | {"log_message":"(I) PATCH /v1/vaults/X/items/X","timestamp":"2023-03-01T16:34:11.896995668Z","level":3,"scope":{"request_id":"3f2a15c4-953a-424b-ba6e-f38ff52f461d"}}

compose-op-connect-api-1   | {"log_message":"(I) PATCH /v1/vaults/X/items/X completed (400: Bad Request) in 31ms","timestamp":"2023-03-01T16:34:11.928466168Z","level":3,"scope":{"request_id":"3f2a15c4-953a-424b-ba6e-f38ff52f461d"}}
{"status":400,"message":"Invalid request body or parameter"}
@mjpieters
Copy link

mjpieters commented Dec 16, 2023

This is not a Connect bug, but an error in how you send the request.

The top-level type of a JSON patch is an array, but you are posting a single object. Moreover, your curl example uses double quotes around the JSON string, which means the double quotes in the value are not sent to the server.

This works fine for me; the following changed your curl command to send an array and to use single quotes around the JSON string so the value includes the double quotes.

curl -i -X PATCH $OP_CONNECT_HOST/v1/vaults/$OP_VAULT/items/$OP_ITEM_ID \
    -H "Content-Type: application\json" \
    -H "Authorization: Bearer $OP_CONNECT_TOKEN" \
    -d '[ { "op": "replace", "path": "/title", "value": "hello-world" } ]'

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