Skip to content

Worker crashes with EncoderFallbackException when telemetry truncation splits a surrogate pair #4834

Open

Description

@pjdotson

Describe the bug

The worker can crash with EncoderFallbackException when an error annotation has an emoji at the 256-character mark. The step then has no conclusion, and the job log is lost (BlobNotFound).

Cause, from reading the source:

  1. ExecutionContext.PublishStepTelemetry truncates each issue with issue.Message[.._maxIssueMessageLengthInTelemetry], where the limit is 256 UTF-16 code units. This can cut a surrogate pair and leave a lone high surrogate.
  2. The same method writes that text to the diagnostic log through Trace.Info.
  3. HostTraceListener uses new StreamWriter(logStream). Its default encoding throws on invalid surrogates, so the next flush throws.
  4. The exception ends the worker. A later flush in Tracing.Dispose throws again, so the process exits with an unhandled exception.

issue.Message[.._maxIssueMessageLength] in ExecutionContext.AddIssue slices the same way and may have the same problem.

To Reproduce

I did not run these steps. They come from the code path above, and they need the step to have telemetry enabled.

  1. Run a step that prints an error annotation with an emoji across the limit:

    printf '::error::%s😀\n' "$(printf 'a%.0s' {1..255})"
  2. See the worker crash when the step completes.

Expected behavior

Truncation does not split a surrogate pair, and a telemetry or diagnostic log write cannot crash the worker. For example, trim a trailing high surrogate after the slice.

Runner Version and Platform

GitHub-hosted ubuntu-latest. The exact version is unknown because the log is gone. The code path is in main and v2.338.2.

What's not working?

We saw this once in about 2,900 failed jobs. The job failed on 2026-11-03: https://github.com/synnaxlabs/synnax/actions/runs/41729789826/job/126248283947

The step was a Vitest run. Vitest's github-actions reporter prints failures as ::error annotations, and that branch adds a spec with "😀".repeat(200). That this spec was the trigger is inferred, because the log is gone.

The annotation showed:

System.Text.EncoderFallbackException: Unable to translate Unicode character \\uD83D at index 867 to specified code page.
   at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(String value)
   at System.Diagnostics.TextWriterTraceListener.Write(String message)
   at GitHub.Runner.Common.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
   at GitHub.Runner.Worker.Worker.RunAsync(String pipeIn, String pipeOut)
   at GitHub.Runner.Worker.Program.MainAsync(IHostContext context, String[] args)

Job Log Output

Not available. The log request returns BlobNotFound.

Runner and Worker's Diagnostic Logs

Not available on a GitHub-hosted runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions