Skip to content

Conversation

@Eijebong
Copy link
Contributor

@Eijebong Eijebong commented Jun 2, 2025

Taskcluster sends those without a content-type which means that requests assumes they're latin1 text, which they might not be as taskgraph uploads its YAMLs encoded as UTF-8. While decoding UTF-8 as latin1 works most of the time, if the commit message passed in a parameters.yml contains a special character, then it will return a garbled mess which the yaml library will reject.

By passing the raw bytes instead of decoding them, we sidestep the problem entirely, delegating the decoding to the YAML library which supports both utf-8 and utf-16s.

From the documentation for yaml.load

A byte string or a file must be encoded with utf-8, utf-16-be or
utf-16-le encoding. yaml.load detects the encoding by checking the BOM
(byte order mark) sequence at the beginning of the string/file. If no
BOM is present, the utf-8 encoding is assumed.

@Eijebong Eijebong requested a review from a team as a code owner June 2, 2025 10:15
@Eijebong Eijebong requested a review from hneiva June 2, 2025 10:15
Taskcluster sends those without a content-type which means that requests
assumes they're latin1 text, which they might not be as taskgraph uploads
its YAMLs encoded as UTF-8. While decoding UTF-8 as latin1 works most of
the time, if the commit message passed in a parameters.yml contains a
special character, then it will return a garbled mess which the yaml
library will reject.

By passing the raw bytes instead of decoding them, we sidestep the
problem entirely, delegating the decoding to the YAML library which
supports both utf-8 and utf-16s.

From the documentation for `yaml.load`

> A byte string or a file must be encoded with utf-8, utf-16-be or
> utf-16-le encoding. yaml.load detects the encoding by checking the BOM
> (byte order mark) sequence at the beginning of the string/file. If no
> BOM is present, the utf-8 encoding is assumed.
@Eijebong Eijebong force-pushed the dont-decode-yaml-content-ourselves branch from 0f72e01 to 75ff3b7 Compare June 2, 2025 10:19
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