fix(unit-only): Replace the harness-only --logs success-return block in... (#1406)#51
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(unit-only): Replace the harness-only --logs success-return block in... (#1406)#51aidandaly24 wants to merge 1 commit into
--logs success-return block in... (#1406)#51aidandaly24 wants to merge 1 commit into
Conversation
Harness-only projects have no local dev server to tail logs from. The --logs branch previously deployed, printed informational invoke guidance, and returned a success result that flowed to process.exit(0), making the flag a silent no-op. Throw a ValidationError instead so the outer try/catch exits 1, matching sibling validation failures in the command. Fixes aws#1406
Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs aws#1406
Issues
@preview/BUILD_PREVIEW=1), runningagentcore dev --logson a harness-only project prints informational guidance and exits 0 instead of exiting 1 with a validation error. This breaks scripts/CI that rely on the exit code to detect no dev server started. It does NOT affect any GA (@latest) release: the harness branch is preview-gated and dead-code-eliminated from the GA bundle, and harness projects can only be created in preview builds anyway.Root cause
At command.tsx:363 the branch
if (isPreviewEnabled() && supportedAgents.length === 0 && hasHarnesses)optionally deploys then prints invoke guidance and ends withreturn { success: true as const, blockingPromise: Promise.resolve() }(line 376). That success result flows out ofwithCommandRunTelemetryto lines 552-554 (if (!serverResult.success) throw ...; await serverResult.blockingPromise; process.exit(0)), so the process exits 0. Sibling validation failures in the same command correctlythrow new ValidationError(...)(e.g. 327-331, 343-347, 379-384, 392-394) which the outer try/catch at 555-558 turns intoprocess.exit(1). Decisive context the brief understated: the branch is gated onisPreviewEnabled()(line 363) andhasHarnessesis itselfisPreviewEnabled() && ...(line 325).__PREVIEW__is a compile-time esbuild define (esbuild.config.mjs:56,process.env.BUILD_PREVIEW === '1' ? 'true' : 'false'). The GA publish jobpublish-mainrunsnpm run buildwith NOBUILD_PREVIEW(release-main-and-preview.yml:309), so__PREVIEW__is literalfalseand the branch is dead-code-eliminated underminify: true. Harness creation is also preview-only (create command.tsx:516), so the issue's repro only produces a harness project in a preview build. Bug is real and present at v0.20.2 HEAD (commit e92c79a) but exercisable only in preview builds.The fix
Replace the success return at command.tsx:376 (and collapse the surrounding deploy+guidance block 363-377) with
throw new ValidationError('Harness projects do not support local dev. Use \agentcore invoke --harness ` instead.'). ValidationError is already imported (line 5) and is caught by the outer try/catch at 555-558 which calls process.exit(1). This is exactly what closed PR #1450 did. One design decision to settle with maintainers before re-landing: whether the pre-throwrunCliDeploy()` (lines 365-367) served a purpose — Hweinstock raised this in the PR review and it was taken to DM, so confirm fail-fast vs deploy-then-fail semantics before applying. Note this fix only changes preview behavior; GA is unaffected either way.Files touched: /local/home/aidandal/workplace/issues/agentcore-cli/src/cli/commands/dev/command.tsx — harness-only
--logsbranch at lines 361-377 (specifically thereturn { success: true ... }at line 376). Owner repo: agentcore-cli (CLI). No CDK/SDK/service handoff.Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.