这是indexloc提供的服务,不要输入任何密码
Skip to content

withAuthContext firestore functions cause error in emulator #7037

@Bullfrog1234

Description

@Bullfrog1234

Related issues

No related issues found.
The capability was added through the firebase/firebase-functions#1519
 

[REQUIRED] Version info

node: v20.11.0

firebase-functions: v4.9.0

firebase-tools: v13.7.2

firebase-admin: v12.0.0

[REQUIRED] Test case

  1. Create a new event trigger function for onDocumentCreatedWithAuthContext
  2. Build the code if using typescript
  3. Run the emulators
  4. Watch it fail to run the emulators

The error returned from firebase-tools is:

[warn] !  Unexpected rules runtime error: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "line" is null
	at com.google.firebase.rules.tools.local.server.Server.processRequestsFromInputStream(Server.java:75)
	at com.google.firebase.rules.tools.local.server.Server.start(Server.java:57)
	at com.google.firebase.rules.tools.local.FirebaseRulesTooling.main(FirebaseRulesTooling.java:81)
 {"metadata":{"emulator":{"name":"storage"},"message":"Unexpected rules runtime error: Exception in thread \"main\" java.lang.NullPointerException: Cannot invoke \"String.length()\" because \"line\" is null\r\n\tat com.google.firebase.rules.tools.local.server.Server.processRequestsFromInputStream(Server.java:75)\r\n\tat com.google.firebase.rules.tools.local.server.Server.start(Server.java:57)\r\n\tat com.google.firebase.rules.tools.local.FirebaseRulesTooling.main(FirebaseRulesTooling.java:81)\r\n"}}
[info] i  logging: Stopping Logging Emulator {"metadata":{"emulator":{"name":"logging"},"message":"Stopping Logging Emulator"}}
[error] 
[error] Error: HTTP Error: 500, [object Object]
[debug] [2024-04-13T13:44:30.399Z] Error Context: {
  "body": {
    "error": {
      "code": 500,
      "status": "UNKNOWN"
    }
  },
  "response": {
    "statusCode": 500
  }
}

Inspecting the java error shows the issue:

 Unsupported eventType: google.cloud.firestore.document.v1.created.withAuthContext; Supported ones: [google.cloud.firestore.document.v1.created, google.cloud.firestore.document.v1.deleted, google.cloud.firestore.document.v1.updated, google.cloud.firestore.document.v1.written]

[REQUIRED] Steps to reproduce

As above

[REQUIRED] Expected behavior

Either:

  • Warning in the emulator output that it is not supported and not load it and continue with emulating the rest
  • Emulate the new Firestore triggers (Preferred)

[REQUIRED] Actual behavior

Errors are returned on emulator start. Have to disable new functions to get emulators to run.

Were you able to successfully deploy your functions?

Not relevant to this error as it relates to the emulators

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions