Skip to content

fix(cloud): decode the aws cli output as utf-8 - #23946

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
IngridMorstrad:fix/cloud-aws-utf8-decode
Oct 25, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
IngridMorstrad:fix/cloud-aws-utf8-decode

Conversation

@IngridMorstrad

@IngridMorstrad IngridMorstrad commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: kirocrew cloud shows the aws CLI's non-ASCII output correctly on Windows instead of mojibake or a crash.

run_aws in src/kiro_crew/cloud/aws.py spawned the aws CLI with text=True and no encoding=. Python then decodes the child's stdout and stderr with the locale code page, which on Windows is the ANSI code page (cp1252, cp936, ...). The child writes UTF-8, so a non-ASCII stack name, path or localized AWS error comes back garbled, and a byte that is not valid in the decoding raises UnicodeDecodeError out of communicate().

Why it matters

Every kirocrew cloud command (launch, connect, IAM checks, CloudFormation deploys) goes through run_aws. A Windows user with a non-ASCII profile path, resource name or a localized error message gets an unreadable error, or a traceback instead of the CLI's real message.

Not a goal

  • Other aws spawn sites (deploy/engine.py, the artifact-deploy skill scripts). They are separate entries in the same baseline.
  • Changing the env handed to the aws child.

What changed (motivation → approach → change)

The aws child writes UTF-8 on every platform: it inherits the PYTHONUTF8=1 that ensure_utf8_console publishes, and aws-cli honours it (aws/aws-cli#8312). The bug is only on our side of the pipe: we decoded with the locale.

run_aws now passes the shared UTF8_TEXT mapping from subprocess_utf8.py (encoding="utf-8", errors="replace") to popen_limited in place of text=True, the same shape the repo's other fixed sites use. A malformed byte becomes U+FFFD in that spot instead of failing the call. The cloud/aws.py entry is removed from .github/subprocess-encoding-baseline.txt with --update-baseline.

Touches the same run_aws Popen as #14207; compatible, 1-line import overlap.

Backwards compatibility

Compatible: POSIX already decoded as UTF-8; the only behaviour change is that Windows decodes the aws CLI's UTF-8 correctly and an invalid byte no longer raises.

Removes nothing: the change narrows nothing and deletes no path, key or record; the baseline file only drops the now-fixed entry.

Tests

  • test/test_cloud_aws.py::TestRunAws::test_spawn_decodes_child_output_as_utf8 pins the text/encoding/errors kwargs run_aws hands popen_limited.
  • test/test_cloud_aws.py::TestATimedOutCallReturnsWhileAHelperHoldsThePipes::test_utf8_output_decodes_and_a_bad_byte_degrades runs a real child that writes café, an invalid 0xff byte and ✓, and expects ("café \ufffd", "✓"). On main it raises UnicodeDecodeError.

Proof: PROVEN test/test_cloud_aws.py::TestRunAws::test_spawn_decodes_child_output_as_utf8 (head 05c5a5a)

Both new tests fail with the fix reverted and pass with it; test/test_cloud_aws.py and test/test_subprocess_encoding_gate.py pass (64 tests).

Manual verification

N/A — unit coverage sufficient: the real-child test exercises the actual popen_limited decode path; no Windows host was available to run the aws CLI itself.

Related Issues

Closes #23944

Sibling sweep

Swept: git grep -lnE "resolve_aws_bin(|aws_spawn_env(" -- src/ cross-checked against .github/subprocess-encoding-baseline.txt
Sibling: src/kiro_crew/deploy/engine.py -- tracked in #23944
Sibling: src/kiro_crew/deploy/skills/artifact-deploy/scripts/attach_backend.py -- tracked in #23944
Sibling: src/kiro_crew/deploy/skills/artifact-deploy/scripts/detach_backend.py -- tracked in #23944
Sibling: src/kiro_crew/cloud/ssm.py -- not affected -- captured calls go through run_aws; the session Popen streams bytes
Sibling: src/kiro_crew/voice_reply.py -- not affected -- asyncio spawns read bytes, no text mode

Pattern harvest

Rule candidate: lint
Pattern: text-mode subprocess call without encoding= (already enforced by scripts/check_subprocess_encoding.py; this PR shrinks its baseline)

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision cf0274bc3c01183cdc8740933f962607739ab232 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of cf0274bc3c01183cdc8740933f962607739ab232 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. This is a single-site fix that reuses the existing UTF8_TEXT mapping and shrinks the encoding baseline. The defect is pinned by a real-child test that fails on base.

What this change ships

Inventory (3 items) — 3 justified

Intent: let kirocrew cloud users on Windows read the aws CLI's non-ASCII output correctly, without garbled text or a crash. This is a FIX.

  1. The aws CLI's non-ASCII output now decodes as UTF-8 on Windows, where it used to decode with the locale code page — justified
  2. An invalid byte in the CLI's output now becomes U+FFFD instead of raising UnicodeDecodeError — justified
  3. The cloud/aws.py entry is removed from the subprocess-encoding baseline — justified

[FIRST-PRINCIPLES-REVIEWED] cf0274b

Description read

[DESCRIPTION-READ] 6ab8a67f96d0361004a1f3d48a4c348b566b39bd3f56ddd8557952348f3e3d91

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of cf0274bc3c01183cdc8740933f962607739ab232 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a small, reversible fix that uses the same UTF8_TEXT decode as the deploy/engine.py and artifact-deploy aws spawn sites.

Notes

  • The fix only holds if the aws CLI really writes UTF-8 on Windows, which depends on it inheriting PYTHONUTF8=1. If the frozen aws-cli v2 binary ignores that variable, the output now shows U+FFFD instead of mojibake, but it no longer crashes. A revert undoes it cleanly, so this is not a blocker. A one-time aws run on a Windows host with a non-ASCII error would confirm the premise.

[DESIGN-REVIEWED] cf0274b

Description read

[DESCRIPTION-READ] 33974b627e2c68d45d940fb1ffd4c5862e24b31867f1c4e738ab3493166215a2

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed cf0274bc3c01183cdc8740933f962607739ab232 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] cf0274b

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed cf0274bc3c01183cdc8740933f962607739ab232 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] cf0274b

@IngridMorstrad

Copy link
Copy Markdown
Contributor Author

Both Backend Tests reds on head b8e0601 are not from this diff (which changes only run_aws's decode in cloud/aws.py):

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 25, 2026
@IngridMorstrad

Copy link
Copy Markdown
Contributor Author

Run 40172702463 finished. All 5 reds trace to known, non-diff causes:

Check Test Cause
Backend Tests (3.12, 2) test_two_concurrent_releases_each_prune_their_own_view flake #23965
Backend Tests (3.12, 4) test_enterprise_unnamed_scope_reports_the_baseline main red, fix #23933
Backend Tests (3.12, 7) test_side_readonly_spec_reap.py::test_an_unreadable_or_protected_checkout_keeps_its_variant flake #23860 (unraisable PosixPath finaliser)
Coverage Gate, PR Readiness -- fail closed on the backend-test reds above

Every run is recorded in its ledger issue. Plan: rebase once #23933 merges, which re-runs everything; a maintainer --failed rerun of shards 2 and 7 would clear the flakes sooner (this fork account cannot rerun upstream jobs).

@IngridMorstrad

Copy link
Copy Markdown
Contributor Author

Security Scope Review on head 05c5a5a is red as [scope-floor:unsettled], not because of a finding. Its fork lane run 40184393110 stalled in the Resolve human override step of the generate job from 10:21Z until the job was cancelled at 10:55Z, so no review leg ran. That is a transient runner stall, so I re-ran the failed jobs once (attempt 2).

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 25, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 25, 2026 12:04

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the cloud AWS CLI runner decodes child output as UTF-8 with replacement, plus tests including a real invalid byte.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 25, 2026
run_aws spawned the CLI with text=True and no encoding, so its stdout
and stderr were decoded with the locale code page. The child inherits
PYTHONUTF8=1 from ensure_utf8_console and writes UTF-8, so on Windows
any non-ASCII stack name, path or localized error on the kirocrew
cloud path came back as mojibake, and an invalid byte raised
UnicodeDecodeError out of communicate(). Splat the shared UTF8_TEXT
mapping (utf-8, errors=replace) and drop the call from the
subprocess-encoding baseline.
@IngridMorstrad
IngridMorstrad force-pushed the fix/cloud-aws-utf8-decode branch from 05c5a5a to cf0274b Compare October 25, 2026 19:58
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 25, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 25, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: decodes the child CLI output as UTF-8 with replacement instead of the locale code page, drops the matching baseline entry, and adds tests.

@KiroCrewCaptain
KiroCrewCaptain merged commit 15ca4b4 into kirodotdev:main Oct 25, 2026
146 of 148 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kirocrew cloud: run_aws decodes aws CLI output with the locale code page (Windows mojibake)

2 participants