Repository navigation
Fix OTLP export of self-referencing arrays - #10670
Open
wikirik-agent wants to merge 1 commit into
Open
wikirik-agent wants to merge 1 commit into
wikirik-agent wants to merge 1 commit into
Conversation
`OtlpResource.unknownToAttributeValue` converted arrays recursively with no cycle check, so a log message, annotation or span attribute holding an array that contains itself overflowed the stack. An array that repeats on the current path now converts to `"[Circular]"`, the marker `Formatter.format` already uses for objects; a shared array without a cycle still converts in full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: da97ba3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
Contributor
|
Update on this; apparently it's more of a hypothetical than something we've actually experienced. An earlier clanker session felt like we needed to do it and the later session moved it upstream as it identified that that was the better solution. I'll let the effect-bot decide if this is worth the improvement |
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OtlpResource.unknownToAttributeValueconverts arrays recursively without a cycle check, so an array that contains itself overflows the stack. Every OTLP path goes through it: the logger's message and annotations, and the tracer's span attributes, events and link attributes. A program that logs such a value, or puts it on a span, dies withRangeError: Maximum call stack size exceeded, while the console logger handles the same value fine:Objects were never affected, because they go through
Formatter.format, which already shows circular references as"[Circular]". This change uses the same marker for arrays. The converter tracks the arrays on the current path, and an array that repeats on that path becomes{ stringValue: "[Circular]" }. An array that appears more than once without a cycle (shared by siblings) still converts in full each time. The set of ancestors is only created for arrays, so non-array values cost nothing extra, and the exported signature is unchanged.Tests cover the converter (a self-referencing array, a cycle through a nested array, a shared array without a cycle) and both exporters end to end (a log message and annotation, a span attribute). Without the fix, the four cycle tests fail with the stack overflow.
Other code that calls
OtlpResourcedirectly gets the fix as well. We found it through Maple's@maple-dev/effect-sdk, whose exporters callOtlpResource.unknownToAttributeValueandentriesToAttributes, and carry this change as a local patch until it's released.Validation: the OtlpResource, OtlpLogger and OtlpTracer tests pass (23);
pnpm lint-fix,pnpm checkandpnpm jsdocs --checkpass.An agent account (
wikirik-agent) posted this. To discuss it with a human, ask @WikiRik.