Skip to content

Sanitize invalid UTF-8 in git metadata - #475

Closed
kurtmc wants to merge 1 commit into
concourse:masterfrom
kurtmc:fix/utf-8-issue
Closed

kurtmc wants to merge 1 commit into
concourse:masterfrom
kurtmc:fix/utf-8-issue

Conversation

@kurtmc

@kurtmc kurtmc commented Jun 15, 2026

Copy link
Copy Markdown

It's possible for invalid UTF-8 characters to get into commit message so we are seeing the following error in production. I've added a sanitise step to elimite this issue.
2026-06-15_12-50

A commit (or branch/tag name) containing invalid UTF-8 made Concourse fail
to marshal the resource metadata into gRPC labels:

  set label: grpc: error while marshaling: string field contains invalid UTF-8

The metadata fields derived from git (author, committer, message, branch,
tags, tag) are now passed through `iconv -f UTF-8 -t UTF-8 -c` before jq, so
invalid bytes are dropped rather than passed through verbatim (or replaced
with U+FFFD by jq, which is version-dependent). glibc-iconv provides iconv in
the resource image.

Adds a unit test and an end-to-end test covering a commit, branch and tag
that carry invalid UTF-8.
@kurtmc
kurtmc requested a review from a team June 15, 2026 00:56
@taylorsilva

Copy link
Copy Markdown
Member

@kurtmc what version of Concourse are you on? Since this issue could affect any resource I prefer trying to fix it in concourse/concourse instead of per each resource type. An initial fix I did was here: concourse/concourse#9430
which landed in v8.1.0. Are you still seeing this error with Concourse >= 8.1.0?

@kurtmc

kurtmc commented Jun 15, 2026

Copy link
Copy Markdown
Author

@taylorsilva we're on v8.2.3

@kurtmc

kurtmc commented Jun 15, 2026

Copy link
Copy Markdown
Author

I'll look into reproducing this issue in the docker compose setup of concourse, so we have a concrete example to look at.

@taylorsilva

Copy link
Copy Markdown
Member

That would be awesome, thank you!

@taylorsilva

Copy link
Copy Markdown
Member

Another idea, since it's fine if we reproduce this with the git resource: can you push a commit that contains the offending string to a public repo somewhere? Maybe fork https://github.com/concourse/examples and add a commit that causes this error.

I recall having quite a time trying to reproduce this since most tools don't let you write non-utf-8 strings now.

@taylorsilva

taylorsilva commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Gave my idea a quick try but no luck reproducing:
image

concourse/examples@main...non-utf8

image

not sure where else to sneak in a non-utf8 character 😕 Hope you can figure out how to reproduce this.

@kurtmc

kurtmc commented Jun 15, 2026

Copy link
Copy Markdown
Author

@taylorsilva I've reproduced the issue locally, and pushed a commit to my examples fork: https://github.com/kurtmc/examples/tree/utf8-emdash-repro

@kurtmc

kurtmc commented Jun 15, 2026

Copy link
Copy Markdown
Author

The issue is here: https://github.com/concourse/concourse/blob/v8.2.3/worker/runtime/properties.go#L43-L49

The byte slice (labelSet[chunkKey] = value[:valueLen] ) can split a multi byte run causing an invalid utf8 character to be in the value, so it can't be marshalled later.

@kurtmc

kurtmc commented Jun 15, 2026

Copy link
Copy Markdown
Author

Closing the PR, as this is an issue in concourse/concourse.

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.

2 participants