Skip to content

Fix IllegalArgumentException: Unrecognized AnyValue type on empty LogRecord.body#2529

Merged
breedx-splk merged 3 commits intoopen-telemetry:mainfrom
dshkil:fix-Unrecognized-AnyValue-type
Jan 30, 2026
Merged

Fix IllegalArgumentException: Unrecognized AnyValue type on empty LogRecord.body#2529
breedx-splk merged 3 commits intoopen-telemetry:mainfrom
dshkil:fix-Unrecognized-AnyValue-type

Conversation

@dshkil
Copy link
Copy Markdown
Contributor

@dshkil dshkil commented Dec 17, 2025

Description:

Bug fix - LogRecord with a body equal to an empty string cannot be mapped to an SDK's Value. It happens on periodic export in the background and causes an unhandled exception.

In this case, AnyValue deserialized using protobuf has all its fields set to null. It makes impossible to determine the original body value type. However, according to LogRecordDataMapper.bodyToAnyValue(), the only possible non-null values are strings.
I suppose the root cause is related to the LogRecord protobuf schema. However, changes to the schema could be problematic, and we also need a workaround for existing data.

java.lang.IllegalArgumentException: Unrecognized AnyValue type
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.LogRecordDataMapper.anyValueToBody(LogRecordDataMapper.java:139)
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.LogRecordDataMapper.mapToSdk(LogRecordDataMapper.java:81)
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.ProtoLogsDataMapper.protoToSignalItem(ProtoLogsDataMapper.java:38)
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.ProtoLogsDataMapper.protoToSignalItem(ProtoLogsDataMapper.java:20)
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.common.BaseProtoSignalsDataMapper.fromProto(BaseProtoSignalsDataMapper.java:59)
	at io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.LogRecordDataDeserializer.deserialize(LogRecordDataDeserializer.java:27)
	at io.opentelemetry.contrib.disk.buffering.internal.storage.Storage.doReadNext(Storage.java:123)
	at io.opentelemetry.contrib.disk.buffering.internal.storage.Storage.readNext(Storage.java:94)
	at io.opentelemetry.contrib.disk.buffering.internal.storage.StorageIterator.findNext(StorageIterator.java:80)
	at io.opentelemetry.contrib.disk.buffering.internal.storage.StorageIterator.hasNext(StorageIterator.java:41)
	at io.opentelemetry.android.features.diskbuffering.SignalFromDiskExporter.export(SignalFromDiskExporter.kt:73)
	at io.opentelemetry.android.features.diskbuffering.SignalFromDiskExporter.exportBatchOfLogs(SignalFromDiskExporter.kt:65)
	at io.opentelemetry.android.features.diskbuffering.SignalFromDiskExporter.exportBatchOfEach(SignalFromDiskExporter.kt:96)
	at io.opentelemetry.android.features.diskbuffering.scheduler.DefaultExportScheduler.onRun(DefaultExportScheduler.kt:31)
	at io.opentelemetry.android.internal.services.periodicwork.PeriodicRunnable.run(PeriodicRunnable.kt:24)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)

Existing Issue(s):

#2530

Testing:

Tested in the app

Documentation:

No functional changes

Outstanding items:

No functional changes

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Dec 17, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@dshkil dshkil marked this pull request as ready for review December 17, 2025 21:22
@dshkil dshkil requested a review from a team as a code owner December 17, 2025 21:22
Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dshkil thanks for catching and addressing this edge case. Would it be possible to please add a test case that covers this? Appreciate it.

@dshkil dshkil force-pushed the fix-Unrecognized-AnyValue-type branch from 66cc014 to 370ed41 Compare January 30, 2026 13:30
@dshkil-spoton
Copy link
Copy Markdown

Unit tests have been updated

Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@breedx-splk breedx-splk added this pull request to the merge queue Jan 30, 2026
Merged via the queue into open-telemetry:main with commit 6770c04 Jan 30, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants