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

Can't encode ProjectGraph (Run entity) #118

Closed
clementguillot opened this issue Apr 22, 2024 · 0 comments · Fixed by #258
Closed

Can't encode ProjectGraph (Run entity) #118

clementguillot opened this issue Apr 22, 2024 · 0 comments · Fixed by #258
Assignees

Comments

@clementguillot
Copy link
Owner

clementguillot commented Apr 22, 2024

Description

When using var instead of val in our Mongo Entities, we are hitting this exception with RunEntity:

org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when encoding using the AutomaticPojoCodec.
Encoding a RunEntity: 'RunEntity(id=6626261252abc431948125e9, workspaceId=6626261252abc431948125e8, command=test command, status=test status, startTime=2024-04-22T10:55:46.629210944, endTime=2024-04-22T10:55:46.629000124, branch=test branch, runGroup=test run group, inner=true, distributedExecutionId=test distributed execution id, ciExecutionId=test ci execution id, ciExecutionEnv=test ci execution env, machineInfo=MachineInfo(machineId=, platform=, version=, cpuCores=0), meta={key=value}, vcsContext=VcsContext(branch=test branch, ref=test ref, title=test title, headSha=test head sha, baseSha=test base sha, commitLink=test commit link, author=test author, authorUrl=test author url, authorAvatarUrl=test author avatar url, repositoryUrl=test repository url, platformName=test platform name), linkId=test link id, projectGraph=ProjectGraph(nodes={node=Node(type=test type, name=test name, data={key=value})}, dependencies={dependency=[Dependency(source=test source, target=test target, type=test type)]}), hashedContributors=[test hashed contributors], sha=test sha)' failed with the following exception:

Failed to encode 'RunEntity'. Encoding 'projectGraph' errored with: Can't find a codec for CodecCacheKey{clazz=class org.nxcloudce.server.persistence.entity.RunEntity$ProjectGraph, types=null}.

A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
	at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42)
	at org.nxcloudce.server.persistence.repository.RunPanacheRepositoryTest$should find entities with 'endTime' older than input$1.invokeSuspend(RunPanacheRepositoryTest.kt:43)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:316)
	Suppressed: java.lang.ClassCastException: class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to class java.lang.Class (sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl and java.lang.Class are in module java.base of loader 'bootstrap')
		at org.bson.codecs.pojo.TypeData.getNestedTypeData(TypeData.java:84)
		at org.bson.codecs.pojo.TypeData.newInstance(TypeData.java:68)
		at org.bson.codecs.pojo.TypeData.newInstance(TypeData.java:55)
		at org.bson.codecs.pojo.PojoBuilderHelper.configureClassModelBuilder(PojoBuilderHelper.java:74)
		at org.bson.codecs.pojo.ClassModelBuilder.<init>(ClassModelBuilder.java:59)
		at org.bson.codecs.pojo.ClassModel.builder(ClassModel.java:69)
		at org.bson.codecs.pojo.PojoCodecProvider.createClassModel(PojoCodecProvider.java:222)
		at org.bson.codecs.pojo.PojoCodecProvider.createCodec(PojoCodecProvider.java:82)
		at org.bson.codecs.pojo.PojoCodecProvider.get(PojoCodecProvider.java:72)
		at org.bson.codecs.configuration.CodecProvider.get(CodecProvider.java:70)
		at org.bson.internal.ProvidersCodecRegistry.getFromCodecProvider(ProvidersCodecRegistry.java:95)
		at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:70)
		at org.bson.internal.ProvidersCodecRegistry.getFromCodecProvider(ProvidersCodecRegistry.java:95)
		at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:70)
		at org.bson.internal.ProvidersCodecRegistry.getFromCodecProvider(ProvidersCodecRegistry.java:95)
		at org.bson.codecs.configuration.OverridableUuidRepresentationCodecProvider.get(OverridableUuidRepresentationCodecProvider.java:47)
		at org.bson.internal.ProvidersCodecRegistry.getFromCodecProvider(ProvidersCodecRegistry.java:95)
		at org.bson.internal.ProvidersCodecRegistry.lambda$get$0(ProvidersCodecRegistry.java:82)
		at java.base/java.util.Optional.orElseGet(Optional.java:364)
		at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:80)
		at org.bson.internal.ChildCodecRegistry.get(ChildCodecRegistry.java:68)
		at org.bson.codecs.pojo.FallbackPropertyCodecProvider.get(FallbackPropertyCodecProvider.java:38)
		at org.bson.codecs.pojo.PropertyCodecRegistryImpl.get(PropertyCodecRegistryImpl.java:52)
		at org.bson.codecs.pojo.LazyPropertyModelCodec.getCodecFromPropertyRegistry(LazyPropertyModelCodec.java:96)
		at org.bson.codecs.pojo.LazyPropertyModelCodec.createCodec(LazyPropertyModelCodec.java:83)
		at org.bson.codecs.pojo.LazyPropertyModelCodec.getPropertyModelCodec(LazyPropertyModelCodec.java:72)
		at org.bson.codecs.pojo.LazyPropertyModelCodec.encode(LazyPropertyModelCodec.java:57)
		at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
		at org.bson.codecs.pojo.PojoCodecImpl.encodeValue(PojoCodecImpl.java:167)
		at org.bson.codecs.pojo.PojoCodecImpl.encodeProperty(PojoCodecImpl.java:146)
		at org.bson.codecs.pojo.PojoCodecImpl.encode(PojoCodecImpl.java:88)
		at org.bson.codecs.pojo.AutomaticPojoCodec.encode(AutomaticPojoCodec.java:50)
		at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
		at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
		at com.mongodb.internal.connection.SplittablePayload$WriteRequestEncoder.encode(SplittablePayload.java:195)
		at com.mongodb.internal.connection.SplittablePayload$WriteRequestEncoder.encode(SplittablePayload.java:182)
		at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
		at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
		at com.mongodb.internal.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:77)
		at com.mongodb.internal.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:59)
		at com.mongodb.internal.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:162)
		at com.mongodb.internal.connection.RequestMessage.encode(RequestMessage.java:136)
		at com.mongodb.internal.connection.CommandMessage.encode(CommandMessage.java:59)
		at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceiveAsync(InternalStreamConnection.java:492)
		at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceiveAsync(UsageTrackingInternalConnection.java:157)
		at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceiveAsync(DefaultConnectionPool.java:802)
		at com.mongodb.internal.connection.CommandProtocolImpl.executeAsync(CommandProtocolImpl.java:83)
		at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.executeAsync(DefaultServer.java:232)
		at com.mongodb.internal.connection.DefaultServerConnection.executeProtocolAsync(DefaultServerConnection.java:122)
		at com.mongodb.internal.connection.DefaultServerConnection.commandAsync(DefaultServerConnection.java:102)
		at com.mongodb.internal.connection.DefaultServer$AsyncOperationCountTrackingConnection.commandAsync(DefaultServer.java:370)
		at com.mongodb.internal.operation.MixedBulkWriteOperation.executeCommandAsync(MixedBulkWriteOperation.java:401)
		at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeBulkWriteBatchAsync$8(MixedBulkWriteOperation.java:303)
		at com.mongodb.internal.async.function.AsyncCallbackLoop.run(AsyncCallbackLoop.java:56)
		at com.mongodb.internal.operation.MixedBulkWriteOperation.executeBulkWriteBatchAsync(MixedBulkWriteOperation.java:337)
		at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeAsync$4(MixedBulkWriteOperation.java:246)
		at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSourceAndConnection$0(AsyncOperationHelper.java:117)
		at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSuppliedResource$2(AsyncOperationHelper.java:133)
		at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$2(AsyncCallbackSupplier.java:101)
		at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSuppliedResource$3(AsyncOperationHelper.java:134)
		at com.mongodb.internal.connection.DefaultServer.lambda$getConnectionAsync$0(DefaultServer.java:130)
		at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)
		at com.mongodb.internal.connection.DefaultConnectionPool.lambda$getAsync$0(DefaultConnectionPool.java:222)
		at com.mongodb.internal.connection.DefaultConnectionPool.lambda$getAsync$1(DefaultConnectionPool.java:245)
		at com.mongodb.internal.connection.DefaultConnectionPool$Task.doComplete(DefaultConnectionPool.java:1445)
		at com.mongodb.internal.connection.DefaultConnectionPool$Task.execute(DefaultConnectionPool.java:1431)
		at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.workerRun(DefaultConnectionPool.java:1375)
		at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.runAndLogUncaught(DefaultConnectionPool.java:1402)
		at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.lambda$initUnlessClosed$1(DefaultConnectionPool.java:1343)
		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
		at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when encoding using the AutomaticPojoCodec.
Encoding a RunEntity: 'RunEntity(id=6626261252abc431948125e9, workspaceId=6626261252abc431948125e8, command=test command, status=test status, startTime=2024-04-22T10:55:46.629210944, endTime=2024-04-22T10:55:46.629000124, branch=test branch, runGroup=test run group, inner=true, distributedExecutionId=test distributed execution id, ciExecutionId=test ci execution id, ciExecutionEnv=test ci execution env, machineInfo=MachineInfo(machineId=, platform=, version=, cpuCores=0), meta={key=value}, vcsContext=VcsContext(branch=test branch, ref=test ref, title=test title, headSha=test head sha, baseSha=test base sha, commitLink=test commit link, author=test author, authorUrl=test author url, authorAvatarUrl=test author avatar url, repositoryUrl=test repository url, platformName=test platform name), linkId=test link id, projectGraph=ProjectGraph(nodes={node=Node(type=test type, name=test name, data={key=value})}, dependencies={dependency=[Dependency(source=test source, target=test target, type=test type)]}), hashedContributors=[test hashed contributors], sha=test sha)' failed with the following exception:

Failed to encode 'RunEntity'. Encoding 'projectGraph' errored with: Can't find a codec for CodecCacheKey{clazz=class org.nxcloudce.server.persistence.entity.RunEntity$ProjectGraph, types=null}.

A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
	at org.bson.codecs.pojo.AutomaticPojoCodec.encode(AutomaticPojoCodec.java:53)
	at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
	at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
	at com.mongodb.internal.connection.SplittablePayload$WriteRequestEncoder.encode(SplittablePayload.java:195)
	at com.mongodb.internal.connection.SplittablePayload$WriteRequestEncoder.encode(SplittablePayload.java:182)
	at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
	at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
	at com.mongodb.internal.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:77)
	at com.mongodb.internal.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:59)
	at com.mongodb.internal.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:162)
	at com.mongodb.internal.connection.RequestMessage.encode(RequestMessage.java:136)
	at com.mongodb.internal.connection.CommandMessage.encode(CommandMessage.java:59)
	at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceiveAsync(InternalStreamConnection.java:492)
	at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceiveAsync(UsageTrackingInternalConnection.java:157)
	at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceiveAsync(DefaultConnectionPool.java:802)
	at com.mongodb.internal.connection.CommandProtocolImpl.executeAsync(CommandProtocolImpl.java:83)
	at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.executeAsync(DefaultServer.java:232)
	at com.mongodb.internal.connection.DefaultServerConnection.executeProtocolAsync(DefaultServerConnection.java:122)
	at com.mongodb.internal.connection.DefaultServerConnection.commandAsync(DefaultServerConnection.java:102)
	at com.mongodb.internal.connection.DefaultServer$AsyncOperationCountTrackingConnection.commandAsync(DefaultServer.java:370)
	at com.mongodb.internal.operation.MixedBulkWriteOperation.executeCommandAsync(MixedBulkWriteOperation.java:401)
	at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeBulkWriteBatchAsync$8(MixedBulkWriteOperation.java:303)
	at com.mongodb.internal.async.function.AsyncCallbackLoop.run(AsyncCallbackLoop.java:56)
	at com.mongodb.internal.operation.MixedBulkWriteOperation.executeBulkWriteBatchAsync(MixedBulkWriteOperation.java:337)
	at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeAsync$4(MixedBulkWriteOperation.java:246)
	at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSourceAndConnection$0(AsyncOperationHelper.java:117)
	at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSuppliedResource$2(AsyncOperationHelper.java:133)
	at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$2(AsyncCallbackSupplier.java:101)
	at com.mongodb.internal.operation.AsyncOperationHelper.lambda$withAsyncSuppliedResource$3(AsyncOperationHelper.java:134)
	at com.mongodb.internal.connection.DefaultServer.lambda$getConnectionAsync$0(DefaultServer.java:130)
	at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)
	at com.mongodb.internal.connection.DefaultConnectionPool.lambda$getAsync$0(DefaultConnectionPool.java:222)
	at com.mongodb.internal.connection.DefaultConnectionPool.lambda$getAsync$1(DefaultConnectionPool.java:245)
	at com.mongodb.internal.connection.DefaultConnectionPool$Task.doComplete(DefaultConnectionPool.java:1445)
	at com.mongodb.internal.connection.DefaultConnectionPool$Task.execute(DefaultConnectionPool.java:1431)
	at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.workerRun(DefaultConnectionPool.java:1375)
	at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.runAndLogUncaught(DefaultConnectionPool.java:1402)
	at com.mongodb.internal.connection.DefaultConnectionPool$AsyncWorkManager.lambda$initUnlessClosed$1(DefaultConnectionPool.java:1343)
	at java.base@21.0.2/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base@21.0.2/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base@21.0.2/java.lang.Thread.run(Thread.java:1583)
Caused by: org.bson.codecs.configuration.CodecConfigurationException: Failed to encode 'RunEntity'. Encoding 'projectGraph' errored with: Can't find a codec for CodecCacheKey{clazz=class org.nxcloudce.server.persistence.entity.RunEntity$ProjectGraph, types=null}.
	at org.bson.codecs.pojo.PojoCodecImpl.encodeValue(PojoCodecImpl.java:171)
	at org.bson.codecs.pojo.PojoCodecImpl.encodeProperty(PojoCodecImpl.java:146)
	at org.bson.codecs.pojo.PojoCodecImpl.encode(PojoCodecImpl.java:88)
	at org.bson.codecs.pojo.AutomaticPojoCodec.encode(AutomaticPojoCodec.java:50)
	... 42 more
Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for CodecCacheKey{clazz=class org.nxcloudce.server.persistence.entity.RunEntity$ProjectGraph, types=null}.
	at org.bson.internal.ProvidersCodecRegistry.lambda$get$0(ProvidersCodecRegistry.java:87)
	at java.base@21.0.2/java.util.Optional.orElseGet(Optional.java:364)
	at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:80)
	at org.bson.internal.ChildCodecRegistry.get(ChildCodecRegistry.java:68)
	at org.bson.codecs.pojo.FallbackPropertyCodecProvider.get(FallbackPropertyCodecProvider.java:38)
	at org.bson.codecs.pojo.PropertyCodecRegistryImpl.get(PropertyCodecRegistryImpl.java:52)
	at org.bson.codecs.pojo.LazyPropertyModelCodec.getCodecFromPropertyRegistry(LazyPropertyModelCodec.java:96)
	at org.bson.codecs.pojo.LazyPropertyModelCodec.createCodec(LazyPropertyModelCodec.java:83)
	at org.bson.codecs.pojo.LazyPropertyModelCodec.getPropertyModelCodec(LazyPropertyModelCodec.java:72)
	at org.bson.codecs.pojo.LazyPropertyModelCodec.encode(LazyPropertyModelCodec.java:57)
	at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
	at org.bson.codecs.pojo.PojoCodecImpl.encodeValue(PojoCodecImpl.java:167)
	... 45 more

Because we have a 3rd level of nested objects (Run > ProjectGraph > Node/Dependency), it may be what's trigger the issue.

We should consider the following options:

  • Move ProjectGraph to a dedicated entity
  • Write a bson Codec w/ CodecProvider
@clementguillot clementguillot converted this from a draft issue Apr 22, 2024
clementguillot added a commit that referenced this issue Oct 28, 2024

Verified

This commit was signed with the committer’s verified signature.
clementguillot Clément Guillot
…ed properly in DB (see #118)
clementguillot added a commit that referenced this issue Oct 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…oken-javalangnullpointerexception

fix(server): temporary disable `ProjectGraph` mapping until it's stored properly in DB (see #118)
@clementguillot clementguillot self-assigned this Nov 2, 2024
@clementguillot clementguillot linked a pull request Nov 2, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Backlog to Done in nx-cloud-ce Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant