fix(server): fall back to text/plain; charset=utf-8 when MIME type is unknown in artifact server#15894
Open
nakatani-yo wants to merge 8 commits intoargoproj:mainfrom
Open
Conversation
bb258fe to
1d958ce
Compare
text/plain; charset=utf-8 when MIME type is unknown in artifact server
…ifact server Signed-off-by: nakatani-yo <yoshihito.nakatani@craftsman-software.com>
…rtifacts Signed-off-by: nakatani-yo <yoshihito.nakatani@craftsman-software.com>
Signed-off-by: nakatani-yo <yoshihito.nakatani@craftsman-software.com>
4f1bd31 to
69c88b6
Compare
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.
Motivation
On the Logs tab of a workflow node, clicking the "logs from the artifacts" link displays garbled text (mojibake) when the log contains non-ASCII characters such as multibyte (e.g. Japanese) text.
This happens because the artifact server runs inside a minimal container image (e.g. distroless) where the system MIME database (
/etc/mime.types) is not available. In that environment,mime.TypeByExtensionreturns an empty string for extensions like.log, and the artifact is served with an emptyContent-Typeheader. Without a properContent-Type, the browser cannot determine the correct character encoding, resulting in garbled text.Modifications
server/artifacts/artifact_server.go, added a fallback so that whenmime.TypeByExtensionreturns an empty string,"text/plain; charset=utf-8"is used as theContent-Typeinstead.server/artifacts/artifact_server_test.go, added a.logartifact (main-logs) to the test fixtures and a test case that verifies theContent-Typeheader is never empty for artifact responses.Verification
.logartifacts that assertsContent-Typeis non-empty..logartifacts are now served withContent-Type: text/plain; charset=utf-8in a distroless container environment.Documentation
This is a bug fix that does not change any user-facing API or configuration. No documentation update is needed.