Repository navigation
fix(diagnose): follow-ups to --symptom-file after #1048 merged - #1094
Conversation
…file input --symptom-file names the offset of the first byte that is not valid UTF-8. After dropping a UTF-8 byte-order mark the offset was counted in what was left, so a file that began with a BOM and then held bad UTF-8 named an offset three bytes too small, against the module's own promise that the error says where decoding failed. The offset now counts from the start of the input, and a test pins it behind a BOM. Also from the review of the original change: say that a file named `-` is passed as `./-`, pin how the advised-command scanner treats `<<<` here-strings, re-wrap an overlong line in docs/wsl.md, and correct the note in docs/testing.md about which CI lanes run the Windows shell forms of diagnose-59: the self-hosted Strix Halo Windows lanes, per pull request and nightly, neither of them required. Follow-up to #1048. Part of ROCMAI-955. Signed-off-by: Eugene Volen <eugene.volen@amd.com>
…lete a CI note The documentation now tells users that a file literally named `-` is passed as `./-`, because `-` alone means standard input. Nothing tested that claim. A unit test now checks that the two spellings are different paths and that a file named `-` is opened as a file. Also complete the note in docs/testing.md about where the Windows shell forms of diagnose-59 run: the self-hosted Strix Halo Windows lane runs on pull requests behind its path filter, on pushes to main and release branches, and in the merge queue, in addition to the scheduled nightly lane. Neither is a required check. Follow-up to #1048. Part of ROCMAI-955. Signed-off-by: Eugene Volen <eugene.volen@amd.com>
Security scan found no critical or high findings on lines changed by this pull requestView the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
juhovainio
left a comment
There was a problem hiding this comment.
I read through the diff and found nothing blocking. The BOM offset fix is correct (BOM + HIP error + 0xFF lands on offset 13), and the README, --help, manual-testing.md and testing.md changes agree with each other. CI is green at this head.
Three small things, none of which block merge:
- The new dash-file test never uses
./-; see the inline comment. The PR body says it does, so either the test or the description could be tightened. - There is no Gherkin scenario for the corrected BOM offset, and the PR text doesn't say why none is needed. A line saying so would be enough.
- The
<<<here-string tests pin existing behaviour; I didn't re-run them locally and relied on CI.
This is a diff read plus CI status, not a local run of the tests.
| // file whatever the working directory. | ||
| #[test] | ||
| fn a_file_named_dash_is_read_as_a_file_not_as_standard_input() { | ||
| assert_ne!(Path::new("./-").as_os_str(), STDIN_PATH); |
There was a problem hiding this comment.
assert_ne! compares two literals, and the resolve below uses an absolute tempdir path, so neither exercises ./-; the test would pass with any non-- path. Consider driving resolve with a real relative ./- path, or note that this only pins the whole-path comparison.
There was a problem hiding this comment.
Agreed, and I took the second option: the description no longer says the test uses ./-. It now says the test compares the two literals and reads a file named - through its absolute path, and that a relative ./- is not driven through resolve because that needs a change of the working directory in parallel tests. I did not change the code, to keep the approved commit as it is. I also added the line on why there is no scenario for the BOM offset.
|
LGTM. Traced the offset fix through the module, it's complete, utf8() is the only Two nits, neither blocking: The "note in docs/testing.md was wrong" bullet doesn't match main, that note is The ./- test doesn't test ./-, the assert_ne compares two literals and the resolve |
juhovainio
left a comment
There was a problem hiding this comment.
Review — no blocking findings
Full review of the whole change.
Fixes the BOM-offset bug and adds the -/./- test/doc follow-ups the PR text says were left over from review of #1048's --symptom-file feature; part of ROCMAI-955 (named but not retrievable from here — no tracker access from this review).
Blocking
None
Non-blocking
None
Decisions for the author
- The new
a_file_named_dash_is_read_as_a_file_not_as_standard_inputtest does not actually driveresolve()with the literal./-spelling — answered-by-intent. It passes an absolute temp path ending in-, plus a standaloneassert_ne!(Path::new("./-").as_os_str(), STDIN_PATH)that is not itself wired into theresolve()call. The PR text explains why: "It does not driveresolvewith a relative./-path, because that needs a change of the process working directory in a parallel test run; the shell-level./-advice is documented, not exercised." That is a reasonable call — astd::env::set_current_dirin a unit test shared with others is genuinely risky — but note an e2e-level alternative exists: a cucumber scenario spawning the real binary with a controlledcwd(asdiagnose-61already does for other usage errors) could exercise the true./-path without touching this process's CWD. Worth considering for a follow-up if this edge ever needs fuller coverage; not a request to change anything now. - No Gherkin scenario for the corrected BOM offset — answered-by-intent. PR text: "AGENTS.md §3 asks for a scenario only where the change alters behaviour the existing diagnose-61 scenarios do not already cover as a refusal (exit 2). The offset digits are not asserted in a scenario." Verified:
diagnose-61's step (tests/e2e-cucumber/tests/e2e/symptom_file_steps.rs::each_file_refused) asserts exit code 2, the file path, "Usage: rocm diagnose", and the generic "is not valid UTF-8" text, but never the specific offset digit — so the exact arithmetic genuinely lives only at unit-test granularity, which AGENTS.md §3 permits ("choose unit/integration/e2e level based on where the bug lives"). - docs/testing.md now names specific GitHub Actions job IDs and workflow filenames (
e2e-gpu-strix-windowsine2e-selfhosted.yml,e2e-gpu-nightly-strix-windowsinnightly.yml) — tradeoff. This is precise and currently accurate (verified against the actual YAML), but it is also more exposed to silently going stale if those lanes are ever renamed, versus a vaguer description that would need no upkeep. Current precision reads as a deliberate, reasonable choice.
Positive signals
- The BOM-offset fix is traced correctly end to end:
decode()passesUTF8_BOM.len()(3) asskippedintoutf8(), which adds it tovalid_up_to(); by hand, BOM +"HIP error "(10 bytes) +0xFFgives3 + 10 = 13, matching the new test's asserted"offset 13"exactly, and the no-BOM path (skipped = 0) reproduces the pre-existing"offset 10"case unchanged. - Naming the magic
3asconst UTF8_BOM: [u8; 3]and reusing its.len()in both thestarts_with/draincall and theskippedargument removes a previously-duplicated literal.
Deployment notes
None — this is a docs/test/error-message change with no migration, API, or runtime-config impact.
What this covered
Diff 0aad1d286ee1c4171c6aab8cf55508605ecb2161...529cd214f00b03f56f3acfc3625bb57a6dc175e8 (7 files, +68/-20), read in full at head plus surrounding context (call sites in apps/rocm/src/main.rs, command_parts/split_shell_list in advised_commands.rs, diagnose.feature + its step definitions, and the three GitHub Actions workflow files named in the docs change). Two independent blind fan-out workers (no visibility into this PR's own description/comments) each reviewed: (1) the code pass over symptom_input.rs / advised_commands.rs / cli.rs, including hand-tracing the here-string parsing and the UTF-16/edge-case offset paths, plus this file's git history; (2) the docs-consistency pass, cross-checking README/manual-testing/testing/wsl.md against the code and against the actual YAML of e2e-selfhosted.yml, nightly.yml, and ci.yml, plus AGENTS.md §3 compliance. Neither surfaced anything at or above the 70-confidence bar. I additionally grepped the repo for other instances of the same BOM/offset-counting pattern (valid_up_to, BOM handling) and for anything else parsing this error text; found no sibling instance of the bug and no other stale documentation of the old behavior.
Did not run: cargo test/clippy locally (not available in this review environment) — relied on manual tracing of the exact code paths instead. CI on the head commit: 54 of 55 checks completed, all success/neutral/skipped; one self-hosted E2E tests (MI300X, current) lane is still queued (not failed) at the time of this review and is unrelated to this docs/test-only change. Not reconciled against this PR's existing review comments/discussion — only the PR description and the named ticket were read, per method, and the ticket (ROCMAI-955) could not be retrieved from here.
🤖 Automated by an AI agent
Why
This follows #1048, which added
rocm diagnose --symptom-fileand was merged before a few points from its review landed. One of them is a real defect, and the rest are small.--symptom-filenames the offset of the first byte that is not valid UTF-8, and its documentation says the error says where decoding failed. After dropping a UTF-8 byte-order mark, the offset was counted in what was left, so a file that began with a BOM and then held bad UTF-8 named an offset three bytes too small. A file with a BOM, ten valid bytes and then0xFFreported "offset 10" for a byte at offset 13.-is reached as./-, because-alone means standard input. Nothing tested it.What changes
decode()andutf8()inapps/rocm/src/symptom_input.rsnow report the offset from the start of the input: the BOM path passes the BOM length and the plain path passes 0. The doc comments say what the offset counts from. A unit test with a BOM,HIP error(10 bytes) and0xFFasserts offset 13. The old code reported 10.-is documented as./-in the README, the--helptext and docs/manual-testing.md, and a unit test checks that the path./-is not the standard-input marker-(a comparison of the two literals) and that a file named-, reached by its absolute path in a temporary directory, is read as a file. It does not driveresolvewith a relative./-path, because that needs a change of the process working directory in a parallel test run; the shell-level./-advice is documented, not exercised.a_heredoc_ends_the_command) gains<<<here-string cases: a trailing<<< "text", a trailing<<<text, and<<< "text" && rocm frobnicate --x, where the second command is still split off and checked. They pin the current behaviour, which was already correct.mainandrelease/**, in the merge queue, and in the scheduled nightly), says none of them is a required check, and that the requiredE2E testsjob runs only the bash half.Verification
Break-the-branch checks: with the BOM length not added back, the BOM test reports offset 10 and fails. With a path ending in
-treated as standard input, the newa_file_named_dash_is_read_as_a_file_not_as_standard_inputtest fails at its assertion. Each was restored afterwards.cargo test --workspace --all-targets --no-fail-fast(AGENTS.md §8), skipping one test belowcargo xtask smoke(AGENTS.md §8)smoke: okcargo clippy --workspace --all-targets -D warnings,cargo clippy -p e2e-cucumber --test e2e -D warnings,cargo fmt --checkcargo nextest run -p rocm(thecargo xtask affectedset)feature_naming,skill_reference, diagnose-59 and -61 (cargo xtask e2e)cargo xtask pre-push-checksteps,verify-commits,check-architecture-doccargo nextest run -p rocmcargo xtask e2e)The full-gate rows were taken on the first commit. The second commit adds one unit test and a docs note, and the rows for it are the last one above.
Failures and instability outside this change:
build_metadata::build_script::tests::git_watch_paths_*fail in WSL2 because that account's git config signs commits with an SSH key that is absent there. On Windows,archive_digest_check_rejects_a_single_bit_of_tamperinginrocm-engine-lemonadehangs on this machine, so the full run skipped it.Scope
--symptom-file -combined with a refusal such as--modeland--distroasks for the paste first. Moving the read after the refusal needs its own scenario. A scenario for the 16 MiB limit is also absent, because the unit tests cover the limit, the exit code and the printed message. diagnose-59 does not assert that the paste's commands did not run, because no shell parses the paste, so the assertion could never fail.Part of ROCMAI-955.
tests/e2e-cucumber/expectations.tomlfor the fixed ticket ID and removed/narrowed any now-stale xfail rows. No rows reference ROCMAI-955.docs/architecture.md. Not applicable: no subcommand or subsystem added../-advice is asserted against the path comparison inresolve.