Skip to content

[Geneva] Fix fuzz tests - #4162

Merged
martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:geneva-fuzz-repro
Apr 21, 2026
Merged

martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:geneva-fuzz-repro

Conversation

@martincostello

Copy link
Copy Markdown
Member

Changes

Handle case where SerializeString_Offset_Near_Buffer_End_Does_Not_Throw would generate inputs that would throw an exception as the encoded string is too large for the buffer.

Example

[xUnit.net 00:00:04.56]     OpenTelemetry.Exporter.Geneva.MetricSerializerTests.SerializeString_Offset_Near_Buffer_End_Does_Not_Throw [FAIL]
[xUnit.net 00:00:04.56]       FsCheck.Xunit.PropertyFailedException : 
[xUnit.net 00:00:04.56]       Falsifiable, after 1000 tests (52 shrinks) (10253591241543748838,13012710626530032541). 
[xUnit.net 00:00:04.56]       Last step was invoked with size of 100 and seed of (11934653490780154147,14955749465213992389).
[xUnit.net 00:00:04.56]       Replay directly at failing step with (11934653490780154147,14955749465213992389,100).
[xUnit.net 00:00:04.56]       Original:
[xUnit.net 00:00:04.56]       (NonEmptyString "IDB\017^^\014]%Y
du\0188\008vl>\011=\028s\0163vm&U3\127F\023dC.v\1275\002\016d
bh{EO].q\027",
 PositiveInt 47) (At least one control character has been escaped as a char code, e.g. \023)
[xUnit.net 00:00:04.56]       Shrunk:
[xUnit.net 00:00:04.56]       (NonEmptyString "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
 PositiveInt 47)
[xUnit.net 00:00:04.56]       
[xUnit.net 00:00:04.56]       ---- System.ArgumentException : The output byte buffer is too small to contain the encoded data, encoding codepage '65001' and fallback 'System.Text.EncoderReplacementFallback'. (Parameter 'bytes')
[xUnit.net 00:00:04.56]       Stack Trace:
[xUnit.net 00:00:04.57]         
[xUnit.net 00:00:04.57]         ----- Inner Stack Trace -----
[xUnit.net 00:00:04.57]            at System.Text.Encoding.ThrowBytesOverflow()
[xUnit.net 00:00:04.57]            at System.Text.Encoding.ThrowBytesOverflow(EncoderNLS encoder, Boolean nothingEncoded)
[xUnit.net 00:00:04.57]            at System.Text.Encoding.GetBytesWithFallback(ReadOnlySpan`1 chars, Int32 originalCharsLength, Span`1 bytes, Int32 originalBytesLength, EncoderNLS encoder, Boolean throwForDestinationOverflow)
[xUnit.net 00:00:04.57]            at System.Text.Encoding.GetBytesWithFallback(Char* pOriginalChars, Int32 originalCharCount, Byte* pOriginalBytes, Int32 originalByteCount, Int32 charsConsumedSoFar, Int32 bytesWrittenSoFar, Boolean throwForDestinationOverflow)
[xUnit.net 00:00:04.57]            at System.Text.UTF8Encoding.GetBytes(ReadOnlySpan`1 chars, Span`1 bytes)
[xUnit.net 00:00:04.57]         /_/test/OpenTelemetry.Exporter.Geneva.FuzzTests/MetricSerializerTests.cs(480,0): at OpenTelemetry.Exporter.Geneva.MetricSerializerTests.SerializeString_Offset_Near_Buffer_End_Does_Not_Throw(NonEmptyString input, PositiveInt nearEnd)
[xUnit.net 00:00:04.57]            at InvokeStub_MetricSerializerTests.SerializeString_Offset_Near_Buffer_End_Does_Not_Throw(Object, Span`1)
[xUnit.net 00:00:04.57]            at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:04.57]         --- End of stack trace from previous location ---
[xUnit.net 00:00:04.57]         C:\Users\kurts\Projects\FsCheck\src\FsCheck\Runner.fs(595,0): at FsCheck.Runner.invokeAndThrowInner@592-1.Invoke(Object[] o)
[xUnit.net 00:00:04.57]         D:\workspace\_work\1\s\src\fsharp\FSharp.Core\reflect.fs(986,0): at <StartupCode$FSharp-Core>.$Reflect.Invoke@986-4.Invoke(T1 inp)
[xUnit.net 00:00:04.57]            at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
[xUnit.net 00:00:04.57]            at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
[xUnit.net 00:00:04.57]            at System.Lazy`1.CreateValue()
[xUnit.net 00:00:04.57]         C:\Users\kurts\Projects\FsCheck\src\FsCheck\Testable.fs(156,0): at FsCheck.Testable.Prop.safeForce[a](Lazy`1 body)

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Handle case where `SerializeString_Offset_Near_Buffer_End_Does_Not_Throw` would generate inputs that would throw an exception as the encoded string is too large for the buffer.
@martincostello
martincostello marked this pull request as ready for review April 20, 2026 14:47
@martincostello
martincostello requested a review from a team as a code owner April 20, 2026 14:47
Copilot AI review requested due to automatic review settings April 20, 2026 14:47
@codecov

codecov Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.80%. Comparing base (77ad374) to head (91f7cb0).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4162      +/-   ##
==========================================
- Coverage   73.83%   73.80%   -0.04%     
==========================================
  Files         466      458       -8     
  Lines       18314    18272      -42     
==========================================
- Hits        13523    13485      -38     
+ Misses       4791     4787       -4     
Flag Coverage Δ
unittests-Exporter.Geneva 55.08% <ø> (-0.60%) ⬇️
unittests-Instrumentation.Cassandra ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an intermittent failure in the Geneva exporter fuzz tests by ensuring SerializeString_Offset_Near_Buffer_End_Does_Not_Throw only exercises inputs that actually fit in the remaining buffer space.

Changes:

  • Add a guard in SerializeString_Offset_Near_Buffer_End_Does_Not_Throw to skip cases where the UTF-8 encoded string cannot fit in the remaining buffer.
  • Tighten SerializeString_Buffer_Too_Small_Throws to assert the thrown exception type is one of the expected buffer-overflow-related exceptions.
  • Add a replay-based repro test intended to capture the previously observed failure seed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martincostello
martincostello added this pull request to the merge queue Apr 21, 2026
Merged via the queue into open-telemetry:main with commit a32c828 Apr 21, 2026
154 of 157 checks passed
@martincostello
martincostello deleted the geneva-fuzz-repro branch April 21, 2026 07:27
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