Repository navigation
fix(runtime): explain harness-managed shell rejections - #2544
aidandaly24 wants to merge 6 commits into
Conversation
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice targeted improvement — turning the opaque Server rejected WebSocket connection: HTTP 400 into an actionable InputValidationError is a real UX win, and the suggested remediation command (agentcore harness exec --id <harness-id> --command <command>) matches the actual flag names in src/handlers/harness/exec/index.tsx.
Verified:
InputValidationErrorsetssource: "user"andexitCode: 2(ExitCode.USAGE), which the test asserts.- The SDK message string in
bedrock-agentcore@0.4.3(session.js:403) is produced exactly asServer rejected WebSocket connection: HTTP ${statusCode}with no trailing reason text, so the strict===comparison inruntimeShell.ts:80matches today. - Tests mock at the
createClientDI boundary rather than atfs/network internals — appropriate, not excessive. - The 403 branch continues to reject with the original error, preserving existing behavior.
One minor, non-blocking observation (ship as-is is fine):
src/core/runtimeShell.ts:80uses exact string equality against the SDK error message. If a future SDK release appends a reason phrase or tweaks capitalization, this detection silently reverts to the old opaque behavior. AstartsWithcheck or a small regex (similar in style to the existingRETRYABLE_UPGRADE) would be marginally more robust. Not required for this PR.
No telemetry gap here — this is an error-source refinement, and routing via AgentCoreCLIError.source is already how the root handler feeds telemetry.
|
Claude Security Review: no high-confidence findings. (run) |
|
Claude Security Review: no high-confidence findings. (run) |
5f661b7 to
d2deecf
Compare
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor #2544 +/- ##
============================================
- Coverage 97.39% 97.39% -0.01%
============================================
Files 642 644 +2
Lines 46910 46939 +29
============================================
+ Hits 45689 45716 +27
- Misses 1221 1223 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| await suspendTerminal(() => run({ stdin, stdout, stderr })); | ||
| } catch (caught) { | ||
| if (!(caught instanceof SilentCLIError)) { | ||
| setError(AgentCoreCLIError.fromError(caught)); |
There was a problem hiding this comment.
I think this changes the exit code for failed shells. Before, any non-silent error went to exit(error), so renderTuiAt rejected and the CLI exited non-zero. Now we catch it, show it, and the only way out is ctrl+c, which calls exit() with no error (line 29). So e.g. agentcore runtime shell --id X with expired creds, or the very 400 this PR is about, ends up exiting 0, and telemetry logs it as a success.
The test "renderTuiAt propagates unexpected shell failures" was removed too, so nothing catches this anymore.
Maybe hang on to the caught error and pass it through on quit, something like if (key.ctrl && input === "c") exit(error ?? undefined), and the same for esc when there's no returnPath? Would be good to bring back a version of that test as well.
| if (error.message !== "Server rejected WebSocket connection: HTTP 400") return undefined; | ||
| return ( | ||
| "If this Runtime is managed by a harness, open its shell with:\n" + | ||
| "agentcore harness shell --id <harness-id>" |
There was a problem hiding this comment.
agentcore harness shell doesn't exist on refactor yet. I think it's coming in #2548? If this merges first, the hint sends people to a command that isn't there. should be fine if our intention is to get the other one in first
Description
Keep rejected
agentcore runtime shellconnections inside the TUI and give HTTP 400 failures an actionable hint, including the case where a harness's backing Runtime was addressed directly.InputValidationErrorcategory and preserve the SDK exception as the cause.Harness shell support is provided by #2548. These PRs are intended to ship together: merge #2548 before this error message starts recommending the new command.
The HTTP 400/403 regression extends the existing non-retryable shell-opener test. The existing unexpected-failure screen test now covers the retained error, hint, retry, endpoint back navigation, and a subsequent successful attempt. No new test files or duplicate terminal test suite.
Related Issue
CLI v1 feedback, item 20. Paired with #2548; no separate GitHub issue was supplied.
Documentation PR
Not applicable. No commands, flags, or help text changed; the error includes the command alternative.
Type of Change
Testing
How have you tested the change?
bun testbun run test:e2e, or explained why they are not applicablebun run typecheckbun run lint:checkbun run format:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed them (not applicable)Results:
bun test src/core/runtimeShell.test.ts src/handlers/runtime/shell: 28 pass, 0 fail.git diff --check: pass.refactor(133fb626); range-diff confirms the rebase did not change any patches.bun testoutside the restricted sandbox: 3,978 pass, 0 fail.--profile deploy: the existing demo harness's backing Runtime returned HTTP 400, the error and separated hint remained in the TUI, retry repeated the request, and Escape returned to the endpoint picker. No resources were created or modified.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.