question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code-guru-profiler: Unable to marshall request to JSON

See original GitHub issue

Describe the bug

When the Code Guru wants to generate a report, it’s unable to properly serialize it using Jackson.

It previously worked though, and this bug has been caued by updating a central awssdk library.

The change occured when updating the software.amazon.awssdk::sns and software.amazon.awssdk::cloudwatch from version 2.17.72 to 2.17.92. The Code Guru profiler is unchanged and at version 1.2.1

Expected behavior

I expect the serialization to work.

Current behavior

ov 30, 2021 4:15:20 PM software.amazon.codeguruprofilerjavaagent.ProfilingCommand reportProfile
INFO: Attempting to report profile data: start=2021-11-30T15:10:19.732821389Z end=2021-11-30T15:15:19.681051401Z force=false memoryRefresh=false numberOfTimesSampled=300
Nov 30, 2021 4:15:20 PM software.amazon.codeguruprofilerjavaagent.flightrecorder.ObjectCountEventProcessor log
INFO: [HeapSummary] Processed 8 events.
Nov 30, 2021 4:15:21 PM software.amazon.codeguruprofilerjavaagent.ProfilingCommand submitProfilingData
INFO: Successfully reported profile
Nov 30, 2021 4:15:22 PM software.amazon.codeguruprofilerjavaagent.profile.metadata.ErrorsMetadata recordSdk
INFO: Exception while calling agent orchestration.
software.amazon.awssdk.core.exception.SdkClientException: Unable to marshall request to JSON: Can not write a field name, expecting a value
	at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98)
	at software.amazon.awssdk.services.codeguruprofiler.transform.ConfigureAgentRequestMarshaller.marshall(ConfigureAgentRequestMarshaller.java:52)
	at software.amazon.awssdk.services.codeguruprofiler.transform.ConfigureAgentRequestMarshaller.marshall(ConfigureAgentRequestMarshaller.java:31)
	at software.amazon.awssdk.core.internal.handler.BaseClientHandler.lambda$finalizeSdkHttpFullRequest$0(BaseClientHandler.java:67)
	at software.amazon.awssdk.core.internal.util.MetricUtils.measureDuration(MetricUtils.java:51)
	at software.amazon.awssdk.core.internal.handler.BaseClientHandler.finalizeSdkHttpFullRequest(BaseClientHandler.java:66)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:151)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:82)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:175)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:76)
	at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:56)
	at software.amazon.awssdk.services.codeguruprofiler.DefaultCodeGuruProfilerClient.configureAgent(DefaultCodeGuruProfilerClient.java:324)
	at software.amazon.codeguruprofilerjavaagent.CodeGuruProfilerSDKClient.configureAgent(CodeGuruProfilerSDKClient.java:108)
	at software.amazon.codeguruprofilerjavaagent.CodeGuruProfilerSDKClient.configureAgent(CodeGuruProfilerSDKClient.java:93)
	at software.amazon.codeguruprofilerjavaagent.ProfilingCommand.callConfigureAgent(ProfilingCommand.java:183)
	at software.amazon.codeguruprofilerjavaagent.ProfilingCommand.refreshConfiguration(ProfilingCommand.java:199)
	at software.amazon.codeguruprofilerjavaagent.ProfilingCommand.startSampling(ProfilingCommand.java:143)
	at software.amazon.codeguruprofilerjavaagent.Timer.time(Timer.java:69)
	at software.amazon.codeguruprofilerjavaagent.ProfilingCommandExecutor.run(ProfilingCommandExecutor.java:78)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Steps to Reproduce

    new Profiler.Builder()
      .profilingGroupName(profile)
      .awsCredentialsProvider(StaticCredentialsProvider.create(awsCredentials))
      .withHeapSummary(true)
      .build()
      .start()

Runs in the background

Possible Solution

No response

Context

No response

AWS Java SDK version used

2.17.92

JDK version used

openjdk version “17.0.1” 2021-10-19

Operating System and version

Amazon Linux 2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
KevinAtSesamcommented, Feb 3, 2022

I think that you’ve found the bug. When I manually define software.amazon.awssdk:codeguruprofiler with version 2.17.121 it works.

[info]     +-software.amazon.awssdk:codeguruprofiler:2.15.4 (evicted by: 2.17.121)
[info]     +-software.amazon.awssdk:codeguruprofiler:2.17.121

This means that there is likely an issue with the package of codeguru itself. Our SBT File after applying the fix:

val awsSdkVersion = "2.17.121"

[...]

// For AWS CodeGuru integration
val awsCodeGuru = "software.amazon.codeguruprofiler" % "codeguru-profiler-java-agent" % "1.2.1"
val awsCodeGuruCore = "software.amazon.awssdk" % "codeguruprofiler" % awsSdkVersion

[...]

libraryDependencies ++= Seq(
  awsCodeGuru,
  awsCodeGuruCore
),

Initially I didn’t include awsCodeGuruCore since I assumed that codeguru-profiler-java-agent would automatically come up with the right version. This is also not mentioned in the documentation:

https://docs.aws.amazon.com/codeguru/latest/profiler-ug/enabling-the-agent-with-code.html

So, two possible actions now:

  • Change the documentation to explicitly mention software.amazon.awssdk:codeguruprofiler in the dependencies
  • Change the software.amazon.codeguruprofiler:codeguru-profiler-java-agent package to properly resolve the latest dependency

Is there any way how I can help further?

0reactions
KevinAtSesamcommented, Feb 7, 2022

@debora-ito mmh. I’ll look into that. We use SBT to compile our application (Written in Scala) and we have it split up in multiple modules. This makes the whole dependency management a bit more involved, but it’s not insurmountable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to marshall request to JSON, Amazon AWS
The error says Unable to marshall request to JSON and java.lang.NoClassDefFoundError: com.google.gson.stream.JsonWriter.
Read more >
Class: AWS.CodeGuruProfiler — AWS SDK for JavaScript
Returns the JSON-formatted resource-based policy on a profiling group. getProfile(params = {}, callback) ⇒ AWS.Request.
Read more >
AWS SDK for Java API Reference - 2.18.38
This section provides documentation for the Amazon CodeGuru Profiler API operations. software.amazon.awssdk.services.codeguruprofiler.endpoints.
Read more >
com.amazonaws.SdkClientException.<init> java code examples
throw new SdkClientException("Invalid argument passed to marshall(...)");... throw new SdkClientException("Unable to marshall request to JSON: " + e.
Read more >
Unable to marshall request to JSON: baseUri must not be null.
Upload file to S3 bucket with AWS Java 2 SDK version 2.15.73 (quite new). Java version 1.8.0_211. Operating system: IBM AIX 7.1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found