firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 916 forks source link

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

Open paulinalewando opened 5 days ago

paulinalewando commented 5 days ago

[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
    }
  2. 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']);


<!-- Provide a minimal, complete, and verifiable example (http://stackoverflow.com/help/mcve) -->

### [REQUIRED] Steps to reproduce
Update the Document: Attempt to update the document, changing the `name` field:

{ "name": "My Document Updated" }

<!-- Provide the steps needed to reproduce the issue with the above test case. -->

### [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.

<!-- What is the expected behavior? -->

### [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



<!-- Run the command with --debug flag, and include the logs below. -->
NickChittle commented 1 day ago

Thanks for reporting this, it seems to be a real issue. We are working on a fix but don't have an ETA on rollout yet.