fix(unit-only): Add dockerfileBaseDir?: string to AddHarnessOptions; re... (#1128)#46
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(unit-only): Add dockerfileBaseDir?: string to AddHarnessOptions; re... (#1128)#46aidandaly24 wants to merge 1 commit into
dockerfileBaseDir?: string to AddHarnessOptions; re... (#1128)#46aidandaly24 wants to merge 1 commit into
Conversation
Relative Dockerfile paths in the agentcore create harness flow resolved against the freshly-created project subdir instead of the invocation cwd, causing a spurious 'Dockerfile not found' error. Add dockerfileBaseDir to AddHarnessOptions and resolve relative paths against options.dockerfileBaseDir ?? projectRoot. Thread the invocation cwd through the CLI create path, createProjectWithHarness, and the TUI flow. projectRoot remains the fallback so standalone add harness is unchanged; absolute paths still bypass via isAbsolute(). Fixes aws#1128
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#1128
Issues
agentcorecommand was run aws/agentcore-cli#1128 — In the previewagentcore createharness flow, when a user supplies a RELATIVE Dockerfile path (e.g../Dockerfileor via--container ./Dockerfile), the CLI resolves it against the freshly-created project directory (cwd/) instead of the directory where they ranagentcore create. The user gets a hardDockerfile not found at: <wrong-path>error even though the file exists where they typed it relative to. Confined to relative paths in the create flow; absolute paths work, and standaloneadd harnessis unaffected (its project root equals the invocation context).Root cause
In src/cli/primitives/HarnessPrimitive.ts:243-246 the relative dockerfilePath is resolved against projectRoot = dirname(configBaseDir); during create, configBaseDir is the newly-minted cwd//agentcore (harness-action.ts:55-56, useCreateFlow.ts:296-297), so resolution happens from cwd/ instead of the invocation cwd. Verified by reading all four files at HEAD; dockerfileBaseDir does not exist in src.
The fix
Add
dockerfileBaseDir?: stringto AddHarnessOptions; resolve relative Dockerfile paths againstoptions.dockerfileBaseDir ?? projectRoot(HarnessPrimitive.ts:246); pass the invocation cwd as dockerfileBaseDir from the CLI create path (command.tsx, capturing getWorkingDirectory() before the outputDir override), from createProjectWithHarness (default?? cwd), and from the TUI path (useCreateFlow.ts,dockerfileBaseDir: cwd). Keeping projectRoot as fallback preserves standaloneadd harness. Absolute paths still bypass via isAbsolute(). This is exactly open PR aws#1474 — merge it.Files touched: src/cli/primitives/HarnessPrimitive.ts (AddHarnessOptions interface + the relative-path resolve at lines 242-246), src/cli/commands/create/command.tsx (handleCreateHarnessCLI ~lines 142, 204), src/cli/commands/create/harness-action.ts (CreateHarnessProjectOptions ~line 21 + the add() call ~line 70), src/cli/tui/screens/create/useCreateFlow.ts (~line 657 harness add). All in the agentcore-cli repo. Fix already authored in OPEN PR aws#1474 (branch fix-create-harness-dockerfile-base).
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
AFTER (fix applied:
const dockerfileBaseDir = options.dockerfileBaseDir ?? projectRoot; resolve(dockerfileBaseDir, dockerfilePath)): same test passes — relative path resolves against dockerfileBaseDir=INVOCATION_CWD, add() returns success:true, copyFile src=resolve('/invocation/cwd','./Dockerfile'), dest=/invocation/cwd/proj/app/support/Dockerfile (lands under agentcore/app//). Fallback test (dockerfileBaseDir omitted) still returns ResourceNotFoundError 'Dockerfile not found at' so standaloneadd harnessis unchanged. Absolute paths bypass via isAbsolute() (untouched branch). New test file: 2/2 pass with fix, 1/2 fails (reproduces symptom) without fix.Plumbing verified: command.tsx captures invocationCwd=getWorkingDirectory() BEFORE --output-dir overrides cwd and passes dockerfileBaseDir=invocationCwd; harness-action.ts defaults dockerfileBaseDir to cwd; useCreateFlow.ts passes cwd. configBaseDir=join(projectRoot,CONFIG_DIR) confirmed to point
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.