firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Unsupported value type VECTOR using `affectedKeys` and `VectorValue`

Open paulinalewando opened this issue 1 year ago • 1 comments

[REQUIRED] Environment info

firebase-tools: 13.11.2

Platform: Windows

[REQUIRED] Test case

Here's a test case that demonstrates the issue:

  1. Firestore Document: Create a Firestore document with a VectorValue field:
{
    "name": "My Document",
    "embeddingVector": [1.0, 2.0, 3.0] // Example vector
}
  1. Security Rules: Implement rules that allow updates only to the name field, use affectedKeys():
function editingOnlyAllowedFields(allowedFields) {
    let editedKeys = request.resource.data.diff(resource.data).affectedKeys();
    return editedKeys.hasOnly(allowedFields);
}

allow update: if editingOnlyAllowedFields(['name']);

[REQUIRED] Steps to reproduce

Update the Document: Attempt to update the document, changing the name field:

{
    "name": "My Document Updated"
}

[REQUIRED] Expected behavior

The expected behavior is for the rules to return true for update and the affectedKeys function to work with the VectorValue field.

[REQUIRED] Actual behavior

FirebaseError: PERMISSION_DENIED: 
evaluation error at L193:30 for 'create' @ L193, evaluation error at L189:30 for 'update' @ L189, Unsupported value type VECTOR for 'update' @ L189

paulinalewando avatar Jun 28 '24 12:06 paulinalewando