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

withAuthContext firestore functions cause error in emulator #7037

Open
Bullfrog1234 opened this issue Apr 13, 2024 · 7 comments
Open

withAuthContext firestore functions cause error in emulator #7037

Bullfrog1234 opened this issue Apr 13, 2024 · 7 comments

Comments

@Bullfrog1234
Copy link

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

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@Bullfrog1234
Copy link
Author

Bullfrog1234 commented Apr 13, 2024

This could also be an issue for firebase tools. Not sure. If so let me know and will raise it there.

@benomatis
Copy link

benomatis commented Apr 21, 2024

I get the same error, despite importing the trigger like this:

import { onDocumentWrittenWithAuthContext } from 'firebase-functions/v2/firestore'

I get the following error

java.lang.IllegalArgumentException: Unsupported eventType: google.cloud.firestore.document.v1.written.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]

For some reason it is trying to use Google Cloud Firestore triggers instead of Firebase Functions Firestore triggers despite the fact it's how it's been imported.

And I can confirm this is definitely an emulator problem only, the function otherwise deploys fine.

@blidd-google blidd-google self-assigned this Apr 22, 2024
@blidd-google blidd-google transferred this issue from firebase/firebase-functions Apr 23, 2024
@blidd-google
Copy link
Contributor

Hi all, I've flagged the issue to the Firestore team and we should have support for the new auth context event types in the next release. Will update this thread once we've released support. Thanks for your patience!

@Bullfrog1234
Copy link
Author

Any news on the timeline for this?

@joehan
Copy link
Contributor

joehan commented May 7, 2024

@Bullfrog1234 This is in the works, we discovered some issues with our initial implementation that we're currently addressing. Unfortunately, due to upcoming code freezes for Google I/O, this will probably be a few more weeks we're able to ship it.

@Bullfrog1234
Copy link
Author

@joehan Thanks for the update and understood about code freeze.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants