Repository navigation
fix(cloud): decode the aws cli output as utf-8 - #23946
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a single-site fix that reuses the existing What this change shipsInventory (3 items) — 3 justifiedIntent: let
[FIRST-PRINCIPLES-REVIEWED] cf0274b Description read[DESCRIPTION-READ] 6ab8a67f96d0361004a1f3d48a4c348b566b39bd3f56ddd8557952348f3e3d91 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a small, reversible fix that uses the same Notes
[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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
Both Backend Tests reds on head b8e0601 are not from this diff (which changes only
|
|
Run 40172702463 finished. All 5 reds trace to known, non-diff causes:
Every run is recorded in its ledger issue. Plan: rebase once #23933 merges, which re-runs everything; a maintainer |
b8e0601 to
05c5a5a
Compare
|
Security Scope Review on head 05c5a5a is red as |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
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.
05c5a5a to
cf0274b
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
Problem / Motivation
Goal:
kirocrew cloudshows the aws CLI's non-ASCII output correctly on Windows instead of mojibake or a crash.run_awsinsrc/kiro_crew/cloud/aws.pyspawned theawsCLI withtext=Trueand noencoding=. 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 raisesUnicodeDecodeErrorout ofcommunicate().Why it matters
Every
kirocrew cloudcommand (launch, connect, IAM checks, CloudFormation deploys) goes throughrun_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
deploy/engine.py, the artifact-deploy skill scripts). They are separate entries in the same baseline.What changed (motivation → approach → change)
The aws child writes UTF-8 on every platform: it inherits the
PYTHONUTF8=1thatensure_utf8_consolepublishes, 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_awsnow passes the sharedUTF8_TEXTmapping fromsubprocess_utf8.py(encoding="utf-8",errors="replace") topopen_limitedin place oftext=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. Thecloud/aws.pyentry is removed from.github/subprocess-encoding-baseline.txtwith--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_utf8pins thetext/encoding/errorskwargsrun_awshandspopen_limited.test/test_cloud_aws.py::TestATimedOutCallReturnsWhileAHelperHoldsThePipes::test_utf8_output_decodes_and_a_bad_byte_degradesruns a real child that writescafé, an invalid0xffbyte and✓, and expects("café \ufffd", "✓"). On main it raisesUnicodeDecodeError.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.pyandtest/test_subprocess_encoding_gate.pypass (64 tests).Manual verification
N/A — unit coverage sufficient: the real-child test exercises the actual
popen_limiteddecode 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)