Skip to content

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
nakatani-yo:fix/artifact-server-content-type-fallback
Open

fix(server): fall back to text/plain; charset=utf-8 when MIME type is unknown in artifact server#15894
nakatani-yo wants to merge 8 commits intoargoproj:mainfrom
nakatani-yo:fix/artifact-server-content-type-fallback

Conversation

@nakatani-yo
Copy link
Copy Markdown
Contributor

@nakatani-yo nakatani-yo commented Apr 9, 2026

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.TypeByExtension returns an empty string for extensions like .log, and the artifact is served with an empty Content-Type header. Without a proper Content-Type, the browser cannot determine the correct character encoding, resulting in garbled text.

image image

Modifications

  • In server/artifacts/artifact_server.go, added a fallback so that when mime.TypeByExtension returns an empty string, "text/plain; charset=utf-8" is used as the Content-Type instead.
  • In server/artifacts/artifact_server_test.go, added a .log artifact (main-logs) to the test fixtures and a test case that verifies the Content-Type header is never empty for artifact responses.

Verification

  • Added a unit test for .log artifacts that asserts Content-Type is non-empty.
  • Verified manually that .log artifacts are now served with Content-Type: text/plain; charset=utf-8 in a distroless container environment.
  • Confirmed that artifact contents containing multibyte characters are displayed correctly without garbled text (mojibake).
image

Documentation

This is a bug fix that does not change any user-facing API or configuration. No documentation update is needed.

@nakatani-yo nakatani-yo marked this pull request as draft April 9, 2026 08:26
@nakatani-yo nakatani-yo closed this Apr 9, 2026
@nakatani-yo nakatani-yo reopened this Apr 9, 2026
@nakatani-yo nakatani-yo closed this Apr 9, 2026
@nakatani-yo nakatani-yo reopened this Apr 9, 2026
@nakatani-yo nakatani-yo force-pushed the fix/artifact-server-content-type-fallback branch from bb258fe to 1d958ce Compare April 13, 2026 13:07
@nakatani-yo nakatani-yo changed the title fix(server): fall back to text/plain when MIME type is unknown in artifact server fix(server): fall back to text/plain; charset=utf-8 when MIME type is unknown in artifact server Apr 13, 2026
…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>
@nakatani-yo nakatani-yo force-pushed the fix/artifact-server-content-type-fallback branch from 4f1bd31 to 69c88b6 Compare April 14, 2026 08:37
Signed-off-by: nakatani-yo <yoshihito.nakatani@craftsman-software.com>
@nakatani-yo nakatani-yo marked this pull request as ready for review April 14, 2026 10:05
@nakatani-yo nakatani-yo reopened this Apr 15, 2026
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.

1 participant