Skip to content

fix(unit-only): Add dockerfileBaseDir?: string to AddHarnessOptions; re... (#1128)#46

Draft
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1128
Draft

fix(unit-only): Add dockerfileBaseDir?: string to AddHarnessOptions; re... (#1128)#46
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1128

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#1128

Issues

  • The path to dockerfile should be fixed to where the agentcore command was run aws/agentcore-cli#1128 — In the preview agentcore create harness flow, when a user supplies a RELATIVE Dockerfile path (e.g. ./Dockerfile or via --container ./Dockerfile), the CLI resolves it against the freshly-created project directory (cwd/) instead of the directory where they ran agentcore create. The user gets a hard Dockerfile 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 standalone add harness is 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?: string to AddHarnessOptions; resolve relative Dockerfile paths against options.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 standalone add 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:

BEFORE (fix reverted in HarnessPrimitive.ts to resolve(projectRoot, dockerfilePath)): the regression test fails reproducing the exact original symptom — a relative dockerfilePath ('./Dockerfile') resolves against projectRoot (/invocation/cwd/proj, the freshly-created project subdir) instead of the invocation cwd; access() throws ENOENT; HarnessPrimitive.add() returns success:false with ResourceNotFoundError 'Dockerfile not found at: /invocation/cwd/proj/Dockerfile'. Vitest: 'expected false to be true' at result.success.

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 standalone add harness is 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.

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
@github-actions github-actions Bot added size/m PR size: M agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.19% 13604 / 36579
🔵 Statements 36.45% 14463 / 39669
🔵 Functions 31.8% 2333 / 7336
🔵 Branches 31.12% 9005 / 28936
Generated in workflow #100 for commit c1bf1f4 by the Vitest Coverage Report Action

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant