Skip to content

fix: fail fast on missing project create dependencies - #2178

Merged
nborges-aws merged 3 commits into
refactorfrom
feat/missing-dep-fail-fast
Sep 3, 2026
Merged

fix: fail fast on missing project create dependencies#2178
nborges-aws merged 3 commits into
refactorfrom
feat/missing-dep-fail-fast

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Description

Add preflight dependency check to agentcore create flow. This change prevents a project scaffolding and a full NPM install from occurring before failing on uv missing.

Create now validates required tools exist before scaffolding project files or starting installation.

  • checks npm when dependency installation is enabled
  • checks uv for Python runtime templates
  • checks git when repository init is enabled
  • added tests asserting that no project files are created and no installation occurs when dependency is missing
nickdb@7cf34dd82df3 agentcore-cli % PATH="$SMOKE_BIN:$PATH" bun run src/index.ts project create --name MissingUvSmoke --template agent-python-strands
Error: 'uv' was not found on your PATH. Install uv: https://docs.astral.sh/uv/getting-started/installation/
nickdb@7cf34dd82df3 agentcore-cli % test ! -e ./MissingUvSmoke && echo "./MissingUvSmoke was not created" || echo "./MissingUvSmoke exists"
./MissingUvSmoke was not created

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • bun run test (2790 pass, 0 fail)
  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added the size/s PR size: S label Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 3, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed claude-security-reviewing Claude Code /security-review in progress agentcore-harness-reviewing AgentCore Harness review in progress labels Sep 3, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgentCore Harness Review

Verdict: Looks good

Nice tight fix. Moving checkCreateDependencies ahead of projectTree.write(destination) correctly ensures a missing dependency fails before any files are scaffolded, and the new negative-path test (fails before writing files or running npm when a later dependency is missing) locks that behavior in by asserting commands === [] and that the target directory was never created.

A few things I verified while reviewing:

  • createProjectTree builds an in-memory FsTreeNode and does no I/O, so running the pre-flight check between createProjectTree and projectTree.write is safe.
  • The upfront check keys off scaffoldRuntimeInput?.language === "Python" for uv, while installRuntimeDependencies re-checks based on pyproject.toml existence. The redundant late check is harmless and preserves the existing safety net if the two ever drift.
  • Harness-only paths correctly only check npm + git upfront (the harness scaffold path does no external commands until the shared npm-install/git-init steps).
  • Tests use real temp dirs and only stub runner/checkTool at the process boundary — no excessive mocking.
  • No telemetry needed; this is a bug fix, not a new user-facing feature.

Nothing blocking.

@codecov-commenter

codecov-commenter commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.08%. Comparing base (16db5b4) to head (d86d07a).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2178   +/-   ##
=========================================
  Coverage     97.08%   97.08%           
=========================================
  Files           536      536           
  Lines         36979    36996   +17     
=========================================
+ Hits          35901    35918   +17     
  Misses         1078     1078           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

);

// Validate required tools exist before starting creation flow
await this.checkCreateDependencies(input);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a similar check in the add runtime flow? I believe right now we'll fail after writing files if uv/npm is missing based on the code:

const spec = await this.scaffoldRuntimeResources(outputPath, input.resourceConfig);
if (spec.runtimes) projectSpec.runtimes.push(...spec.runtimes);
if (spec.memories) projectSpec.memories.push(...spec.memories);
if (spec.credentials) projectSpec.credentials.push(...spec.credentials);
yield* this.installRuntimeDependencies(outputPath);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call out. Just updated the PR with a check for this flow as well

@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 2026
Hweinstock
Hweinstock previously approved these changes Sep 3, 2026
Comment thread src/core/project/manager.tsx Outdated
);
}

if (input.resourceType === "runtime") {

@Hweinstock Hweinstock Sep 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could this be inside the switch to avoid the extra branching?

Hoping to clean this up anyway, so I say we merge and comeback.

@nborges-aws
nborges-aws force-pushed the feat/missing-dep-fail-fast branch from 1a89e33 to d86d07a Compare September 3, 2026 16:42
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 3, 2026
@nborges-aws
nborges-aws merged commit 2c800dc into refactor Sep 3, 2026
22 checks passed
@nborges-aws
nborges-aws deleted the feat/missing-dep-fail-fast branch September 3, 2026 17:11
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.

4 participants