Incompatible conversion from Pub/Sub emulator to CloudEvent for `CloudEventsFunction`
@taeold 已经在做这个了。
开始于 2026年3月2日。
评估
这个 Issue 还没有评估数据。
描述
In invoker/core/src/main/java/com/google/cloud/functions/invoker/Event.java, the conditional check for messages originating from the Pub/Sub emulator strips the name field, which is incompatible with this repository's conversion from legacy events to CloudEvent, throwing an exception when calling Resource.from because Resource.name is not nullable. This makes use of CloudEventFunction incompatible with a Pub/Sub emulator setup for local development.
Example stack trace:
2026-02-23 17:25:21 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Missing required properties: name
2026-02-23 17:25:21 at com.google.gson.Gson.fromJson(Gson.java:1381)
2026-02-23 17:25:21 at com.google.gson.Gson.fromJson(Gson.java:1259)
2026-02-23 17:25:21 at com.google.gson.Gson.fromJson(Gson.java:1169)
2026-02-23 17:25:21 at com.google.gson.Gson.fromJson(Gson.java:1106)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.CloudFunctionsContext$Resource.from(CloudFunctionsContext.java:109)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.GcfEvents$EventAdapter.convertToCloudEvent(GcfEvents.java:143)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.GcfEvents.convertToCloudEvent(GcfEvents.java:116)
2026-02-23 17:25:21 at
com.google.cloud.functions.invoker.BackgroundFunctionExecutor$CloudEventFunctionExecutor.serviceLegacyEvent(BackgroundFunctionExecutor.java:325)
2026-02-23 17:25:21 at
com.google.cloud.functions.invoker.BackgroundFunctionExecutor.lambda$serviceLegacyEvent$8(BackgroundFunctionExecutor.java:402)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.BackgroundFunctionExecutor.runWithContextClassLoader(BackgroundFunctionExecutor.java:409)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.BackgroundFunctionExecutor.serviceLegacyEvent(BackgroundFunctionExecutor.java:402)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.BackgroundFunctionExecutor.handle(BackgroundFunctionExecutor.java:345)
2026-02-23 17:25:21 at org.eclipse.jetty.server.handler.EagerContentHandler.onConditionsMet(EagerContentHandler.java:155)
2026-02-23 17:25:21 at org.eclipse.jetty.server.handler.ConditionalHandler.handle(ConditionalHandler.java:378)
2026-02-23 17:25:21 at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:794)
2026-02-23 17:25:21 at com.google.cloud.functions.invoker.runner.Invoker$NotFoundHandler.handle(Invoker.java:498)
2026-02-23 17:25:21 at org.eclipse.jetty.server.Server.handle(Server.java:195)
2026-02-23 17:25:21 at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:680)
2026-02-23 17:25:21 at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:411)
2026-02-23 17:25:21 at org.eclipse.jetty.server.internal.HttpConnection$FillableCallback.succeeded(HttpConnection.java:1809)
2026-02-23 17:25:21 at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
2026-02-23 17:25:21 at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:54)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:492)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.epcRunTask(AdaptiveExecutionStrategy.java:428)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:401)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:255)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:204)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:312)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:1009)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1239)
2026-02-23 17:25:21 at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1194)
2026-02-23 17:25:21 at java.base/java.lang.Thread.run(Unknown Source)
2026-02-23 17:25:21 Caused by: java.lang.IllegalStateException: Missing required properties: name
2026-02-23 17:25:21 at
com.google.cloud.functions.invoker.$AutoValue_CloudFunctionsContext_Resource$Builder.build($AutoValue_CloudFunctionsContext_Resource.java:108)
2026-02-23 17:25:21 at
com.google.cloud.functions.invoker.AutoValue_CloudFunctionsContext_Resource$GsonTypeAdapter.read(AutoValue_CloudFunctionsContext_Resource.java:118)
2026-02-23 17:25:21 at
com.google.cloud.functions.invoker.AutoValue_CloudFunctionsContext_Resource$GsonTypeAdapter.read(AutoValue_CloudFunctionsContext_Resource.java:25)
2026-02-23 17:25:21 at com.google.gson.Gson.fromJson(Gson.java:1358)
2026-02-23 17:25:21 ... 31 more
2026-02-23 17:25:21
This issue does not affect BackgroundFunction as Resource.from is not called when servicing legacy events without conversion.
- 主要语言
- Java
- 星标
- 154
- 派生
- 63
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GoogleCloudPlatform/functions-framework-java 的其他 Issue
-
enhancement P2
难度 1/5 1 小时以内 新手友好度 65/100
-
enhancement P2
难度 5/5 一周以上 新手友好度 30/100
GoogleCloudPlatform/functions-framework-java#372 · 1 条评论 ·
-
enhancement P3
GoogleCloudPlatform/functions-framework-java#261 · 已指派 1 人 ·
-
P3 question
难度 4/5 3-5 天 新手友好度 35/100
GoogleCloudPlatform/functions-framework-java#254 · 1 条评论 ·
-
enhancement P3
GoogleCloudPlatform/functions-framework-java#209 · 已指派 1 人 ·
查看 GoogleCloudPlatform/functions-framework-java 的全部 Issue
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
1.0.0-alpha2 Type/Improvement
难度 2/5 1-3 小时 新手友好度 68/100
wso2/dpdp-accelerator#272 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
infinispan/infinispan#18150 ·
-
area/frontend
难度 2/5 1-3 小时 新手友好度 65/100