Skip to content

Google.Cloud.Firestore Document.UpdateAsync Precondition.MustExist cannot be explicitly set as argument #11361

@SteGaff7

Description

@SteGaff7

Environment details

  • OS: MacOS Sonoma V14.0
  • .NET version: 7.0
  • Package name and version: Google.Cloud.Firestore 3.4.0

Steps to reproduce

  1. If you explicitly set the precondition parameter to Precondition.MustExist in the UpdateAsync method:
await db
        .Collection("path")
        .Document("id")
        .UpdateAsync("field", value, Precondition.MustExist, cancellationToken);

an exception is thrown

Cannot specify a must-exist precondition for update (Parameter 'precondition')
      System.ArgumentException: Cannot specify a must-exist precondition for update (Parameter 'precondition')
         at Google.Api.Gax.GaxPreconditions.CheckArgument(Boolean condition, String paramName, String message)
         at Google.Cloud.Firestore.WriteBatch.Update(DocumentReference documentReference, IDictionary`2 updates, Precondition precondition)
         at Google.Cloud.Firestore.DocumentReference.UpdateAsync(IDictionary`2 updates, Precondition precondition, CancellationToken cancellationToken)

However if you leave this as null which is equivalent to Must Exist ("May be null, which is equivalent to MustExist.") it works as expected.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the Firestore API.externalThis issue is blocked on a bug with the actual product.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions