Skip to content

feat(targets): allow hyphens in target names - #2577

Merged
notgitika merged 1 commit into
aws:refactorfrom
notgitika:feat/target-name-hyphens
Oct 13, 2026
Merged

notgitika merged 1 commit into
aws:refactorfrom
notgitika:feat/target-name-hyphens

Conversation

@notgitika

Copy link
Copy Markdown
Contributor

Description

Deployment target names can now contain hyphens (for example prod-us), using the exact v0 rule ^[a-zA-Z][a-zA-Z0-9-]*$. v0 projects already have names like this and can't rename them, because the stack name depends on them.

The add-time length check (requireDeployedNameFits) now predicts the name the way the L3 composes it: with the _ separator the target's hyphens become underscores; - and / keep them. That's the only place the CLI builds a physical name from a target. Deployed lookups read the real stack name from CloudFormation, and credential provider names allow -.

Depends on aws/agentcore-l3-cdk-constructs#421. Without it, a v1 project with a hyphenated target passes validation but fails at synth. Land that first and bump the library.

There's deliberately no collision check across targets (see the L3 PR).

Type of Change

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

Testing

  • I ran bun test
  • End-to-end tests are not applicable: schema and add-time validation only (4106 passed)
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check

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 added an appropriate example to the documentation to outline the feature, or no new docs are needed

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 Oct 12, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added claude-security-reviewing Claude Code /security-review in progress agentcore-harness-reviewing AgentCore Harness review in progress labels Oct 12, 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 Oct 12, 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

The change is tightly scoped and the risk model is well captured in the PR description:

  • DeploymentTargetNameSchema is relaxed from alphanumeric-only to ^[a-zA-Z][a-zA-Z0-9-]*$, matching the v0 CLI's exact rule so existing projects with names like prod-us keep validating.
  • requireDeployedNameFits in src/handlers/project/add/shared.ts is the only place where the CLI composes a physical name from a target, and it now mirrors the L3 behavior (hyphens stay for -//-separated resources, hyphens become underscores for _-separated resources). Length is preserved under the transform, so the add-time check stays accurate.
  • Tests exercise both separators with a hyphenated target and use real on-disk aws-targets.json instead of mocking (good).
  • The dependency on agentcore-l3-cdk-constructs#421 is called out in the description, and the deliberate decision not to add a cross-target collision check is explained.

A few things I verified that are not blockers, just noting so the author knows they were considered:

  • The regex permits trailing hyphens (e.g. trailing-). This flows into the CFN stack name AgentCore-<project>-<target>, which CFN permits, and does not reach ECR (which composes ${project}/${agentName} without the target). So this is fine, and it matches v0 behavior.
  • The error message in requireDeployedNameFits reports the raw target (prod-us1) as "longest declared target" while the composed deployed name shows prod_us1. Slight UX asymmetry, but the composed name is right there in the same message, so a user can see what happened.

No telemetry additions needed — this is a validation plumbing change with no new user-facing feature surface.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Oct 12, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.54%. Comparing base (5d81751) to head (062345c).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2577   +/-   ##
=========================================
  Coverage     97.54%   97.54%           
=========================================
  Files           657      657           
  Lines         48779    48780    +1     
=========================================
+ Hits          47580    47581    +1     
  Misses         1199     1199           

☔ 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.

@notgitika
notgitika marked this pull request as ready for review October 13, 2026 07:19
@notgitika
notgitika merged commit 89e7d62 into aws:refactor Oct 13, 2026
21 of 22 checks passed
@notgitika
notgitika deleted the feat/target-name-hyphens branch October 13, 2026 14:49
notgitika pushed a commit to notgitika/agentcore-cli that referenced this pull request Oct 13, 2026
aws#2575 and aws#2577

agentcore migrate replaces the preview and apply subcommands, following
the Terraform apply model: it checks the project and prints the plan, then
applies it. Applying lands next, so for now it prints the plan, says
applying isn't available yet, and exits 0 when the plan is ready and 1
when it isn't.

With aws#2575 merged, agentcore deploy deploys a v0 project with the v0 CLI,
so the steps the plan suggests use it instead of npx @aws/agentcore@0.
With aws#2577 merged, hyphenated target names are valid in v1, so they no
longer block a migration.
@notgitika notgitika mentioned this pull request Oct 13, 2026
10 of 18 tasks
notgitika pushed a commit to notgitika/agentcore-cli that referenced this pull request Oct 13, 2026
aws#2575 and aws#2577

agentcore migrate replaces the preview and apply subcommands, following
the Terraform apply model: it checks the project and prints the plan, then
applies it. Applying lands next, so for now it prints the plan, says
applying isn't available yet, and exits 0 when the plan is ready and 1
when it isn't.

With aws#2575 merged, agentcore deploy deploys a v0 project with the v0 CLI,
so the steps the plan suggests use it instead of npx @aws/agentcore@0.
With aws#2577 merged, hyphenated target names are valid in v1, so they no
longer block a migration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants