Skip to content

fix: use UTF-8 for build graph persistence - #9323

Open
ahmedkhan1 wants to merge 1 commit into
aws:developfrom
ahmedkhan1:fix/issue-7714-build-graph-utf8
Open

ahmedkhan1 wants to merge 1 commit into
aws:developfrom
ahmedkhan1:fix/issue-7714-build-graph-utf8

Conversation

@ahmedkhan1

Copy link
Copy Markdown

Which issue(s) does this change fix?

Fixes #7714

Why is this change necessary?

BuildGraph uses the locale-default encoding for build.toml. On Windows locales such as CP1252, cached builds with non-ASCII paths fail with UnicodeEncodeError.

How does it address the issue?

Read and write build.toml explicitly as UTF-8, including source-hash updates. Add a regression test that simulates a CP1252 locale and round-trips a Greek code path.

What side effects does this change have?

Existing ASCII build graphs remain valid because ASCII is a subset of UTF-8. Build graphs containing non-ASCII data are now persisted consistently across locales.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Review the generative AI contribution guidelines
  • Add input/output type hints to new functions/methods (not applicable; no new production functions or methods)
  • Write design document if needed (Do I need to write a design document?) (not needed for this targeted bug fix)
  • Write/update unit tests
  • Write/update integration tests (not needed; covered at the BuildGraph persistence boundary)
  • Write/update functional tests if needed (not needed)
  • make pr passes (26 unrelated Windows path failures; 7001 unit tests passed and affected tests pass)
  • make update-reproducible-reqs if dependencies were changed (not applicable; no dependency changes)
  • Write documentation (not needed; no user-facing interface change)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ahmedkhan1
ahmedkhan1 requested a review from a team as a code owner October 9, 2026 11:54
@github-actions github-actions Bot added area/build sam build command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Oct 9, 2026
document = {}
try:
txt = self._filepath.read_text()
txt = self._filepath.read_text(encoding="utf-8")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an existing file was written with CP1252, would there be a problem that we're now reading it as utf-8? I think the utf-8 encoding would throw an error because it couldn't parse non-ASCII characters (at least according to this Stack Overflow answer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: sam build - UnicodeEncodeError

2 participants