Fix garbled PF_ConsoleLogs.txt when collecting Linux container logs#208
Draft
Fix garbled PF_ConsoleLogs.txt when collecting Linux container logs#208
Conversation
…rbage characters in PF_ConsoleLogs.txt The Docker API returns a multiplexed stream with 8-byte binary headers per frame when the container is not running with TTY. The previous code read this stream using StreamReader.ReadLine(), which treated the binary headers as text, producing garbled characters (e.g., ��������) in the log file. Added DemuxDockerStream method that properly parses the Docker multiplexed stream format by reading and stripping the 8-byte headers (stream type + padding + payload size) before extracting the UTF-8 payload content. Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/3632fce0-9338-4fa3-a907-6ada665fc04c Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix formatting of PF_ConsoleLogs.txt for linux containers
Fix garbled PF_ConsoleLogs.txt when collecting Linux container logs
Mar 30, 2026
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.
Docker's
GetContainerLogsAsyncreturns a multiplexed stream with 8-byte binary headers per frame (stream type, padding, big-endian uint32 payload size). The existing code reads this raw stream withStreamReader.ReadLine(), so those binary headers appear as��������garbage in the log file.Changes
DockerContainerEngine.CollectLogs: ReplaceStreamReader.ReadLine()withDemuxDockerStream, which parses the Docker multiplexed stream frame-by-frame, stripping headers and writing only UTF-8 payload contentDockerContainerEngine.DemuxDockerStream(new,internal static): Reads 8-byte header → extracts payload size → reads payload → invokes write callback. Loops until stream is exhausted.DockerContainerEngine.ReadExactAsync(new,private static): Ensures exact byte counts are read from the stream, handling partial reads.Docker multiplexed stream format
Also removed an unused
StringBuilderallocation in the same code path.