world-federation-of-advertisers / cross-media-measurement

Apache License 2.0
34 stars 11 forks source link

listReports throws DB JsonNULL exception #794

Open mariolamassaavedra opened 1 year ago

mariolamassaavedra commented 1 year ago

Describe the bug When calling listReports through the reporting server, the DB service is throwing gRPC 999 error: UNKNOWN due to java.lang.ClassCastException: class com.google.gson.JsonNull cannot be cast to class com.google.gson.JsonArray (com.google.gson.JsonNull and com.google.gson.JsonArray are in unnamed module of loader 'app')

Steps to reproduce

  1. Create 1 or more reports
  2. Call listReports method
  3. Error is seen in the postgres-reporting-data-server logs

Component(s) affected Reporting Server

Version 3426f122b6f5fd3040cc7d4e9469596f993fb8be

Environment Origin dev environment

Additional context Tested on Halo's Dev environment and the method works correctly so I am assuming the error is either a config problem on our side, an older code version is being used or we are passing an unexpected value when creating a report that is not supported.

We started with a clean DB, created new event groups, reporting sets and report. Get Report works fine but listReports is returning the error below - I've added the report payload used at the end as well for reference

java.lang.ClassCastException: class com.google.gson.JsonNull cannot be cast to class com.google.gson.JsonArray (com.google.gson.JsonNull and com.google.gson.JsonArray are in unnamed module of loader 'app') at com.google.gson.JsonObject.getAsJsonArray(JsonObject.java:182) at org.wfanet.measurement.reporting.deploy.postgres.readers.ReportReader.buildMetrics(ReportReader.kt:439) at org.wfanet.measurement.reporting.deploy.postgres.readers.ReportReader.buildReport(ReportReader.kt:342) at org.wfanet.measurement.reporting.deploy.postgres.readers.ReportReader.translate(ReportReader.kt:214) at org.wfanet.measurement.reporting.deploy.postgres.readers.ReportReader$listReports$1$1.apply(ReportReader.kt:321) at org.wfanet.measurement.reporting.deploy.postgres.readers.ReportReader$listReports$1$1.apply(ReportReader.kt:321) at org.wfanet.measurement.common.db.r2dbc.QueryResult$consume$1.apply(QueryResult.kt:46) at org.wfanet.measurement.common.db.r2dbc.QueryResult$consume$1.apply(QueryResult.kt:46) at io.r2dbc.postgresql.PostgresqlResult.lambda$map$2(PostgresqlResult.java:123) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:110) at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:250) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:191) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) at io.r2dbc.postgresql.util.FluxDiscardOnCancel$FluxDiscardOnCancelSubscriber.onNext(FluxDiscardOnCancel.java:91) at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onNext(FluxDoFinally.java:113) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:126) at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:814) at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:739) at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:161) at io.r2dbc.postgresql.client.ReactorNettyClient$Conversation.emit(ReactorNettyClient.java:635) at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.emit(ReactorNettyClient.java:887) at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:761) at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:667) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:126) at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224) at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224) at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:279) at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:388) at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:404) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:314) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:435) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1373) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1236) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1285) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800) at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:487) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:385) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829)

This is the payload used to create the report is:

{ "parent": "measurementConsumers/Pk21bxO3Uxc", "report": { "name": "TvYtMeta_Dev_Rep", "report_idempotency_key": "21212", "measurement_consumer": "measurementConsumers/Pk21bxO3Uxc", "event_group_universe": { "event_group_entries": [{ "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MNstouxIrrI/eventGroups/EEORgCqTIaA" }, { "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MNstouxIrrI/eventGroups/czvaOtVs3wE" }, { "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/BIr61uxIrvI/eventGroups/arzzQCpKBrE" }, { "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/BIr61uxIrvI/eventGroups/cVrOzSpKBvU" }, { "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MdIpsOxIryQ/eventGroups/FjCKjdVmSX8" }, { "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MdIpsOxIryQ/eventGroups/I5YT3NVmR_E" }] }, "timeIntervals": { "timeIntervals": [{ "startTime": "2022-10-21T00:00:00Z", "endTime": "2022-10-28T00:00:00Z" }] }, "metrics": [{ "reach": {}, "frequency_histogram": { "maximum_frequency_per_user": "1" }, "set_operations": [{ "unique_name": "TvYtMeta_Test", "set_operation": { "type": "2", "lhs": { "operation": { "type": "1", "lhs": { "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/A28r8NUCQkU" }, "rhs": { "operation": { "type": "1", "lhs": { "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/TZ4e09UBl0I" }, "rhs": { "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/HZqxxir_Lvg" } } } } }, "rhs": { "operation": { "type": "1", "lhs": { "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/epkf4tUAIfo" }, "rhs": { "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/KCgdQtT_iMo" } } } } }] }] } }

SanjayVas commented 1 year ago

Assigning to @tristanvuong2021 to take a look as this sounds like a DB schema/reader issue.

Pretty-printed JSON payload:

{
  "parent": "measurementConsumers/Pk21bxO3Uxc",
  "report": {
    "name": "TvYtMeta_Dev_Rep",
    "report_idempotency_key": "21212",
    "measurement_consumer": "measurementConsumers/Pk21bxO3Uxc",
    "event_group_universe": {
      "event_group_entries": [
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MNstouxIrrI/eventGroups/EEORgCqTIaA"
        },
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MNstouxIrrI/eventGroups/czvaOtVs3wE"
        },
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/BIr61uxIrvI/eventGroups/arzzQCpKBrE"
        },
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/BIr61uxIrvI/eventGroups/cVrOzSpKBvU"
        },
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MdIpsOxIryQ/eventGroups/FjCKjdVmSX8"
        },
        {
          "key": "measurementConsumers/Pk21bxO3Uxc/dataProviders/MdIpsOxIryQ/eventGroups/I5YT3NVmR_E"
        }
      ]
    },
    "timeIntervals": {
      "timeIntervals": [
        {
          "startTime": "2022-10-21T00:00:00Z",
          "endTime": "2022-10-28T00:00:00Z"
        }
      ]
    },
    "metrics": [
      {
        "reach": {},
        "frequency_histogram": {
          "maximum_frequency_per_user": "1"
        },
        "set_operations": [
          {
            "unique_name": "TvYtMeta_Test",
            "set_operation": {
              "type": "2",
              "lhs": {
                "operation": {
                  "type": "1",
                  "lhs": {
                    "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/A28r8NUCQkU"
                  },
                  "rhs": {
                    "operation": {
                      "type": "1",
                      "lhs": {
                        "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/TZ4e09UBl0I"
                      },
                      "rhs": {
                        "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/HZqxxir_Lvg"
                      }
                    }
                  }
                }
              },
              "rhs": {
                "operation": {
                  "type": "1",
                  "lhs": {
                    "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/epkf4tUAIfo"
                  },
                  "rhs": {
                    "reportingSet": "measurementConsumers/Pk21bxO3Uxc/reportingSets/KCgdQtT_iMo"
                  }
                }
              }
            }
          }
        ]
      }
    ]
  }
}
tristanvuong2021 commented 1 year ago

Was this report also used for the successful get report. There also have been some fixes that affect report creation since that version and this might be a creation issue.

mariolamassaavedra commented 1 year ago

Yes this report was the same one we are able to perform a get