Skip to content

bug(cli): digit-led project IDs from init are refused by every deploy and rollback #5169

Closed

Description

@tale-code-bot

Part of #4839 (split from it in task TALE-176).

Problem

#4839 defect 1. Paths are under tools/cli/src/.

# Defect Code What the operator sees
1 A project whose folder name starts with a digit can't be deployed or rolled back. tale init derives the project ID from the folder name and allows a leading digit. tale deploy and tale rollback check the same ID against a rule that requires a letter first lib/project/generate-project-id.ts:7 const VALID_ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;. sanitizePrefix (:16-24) keeps a leading digit, and generateProjectId (:31-45) builds <prefix>-<6 hex> from it (:36). It is called at lib/actions/init.ts:254 and, for a legacy tale.json without an ID, at lib/project/project-context.ts:81 on tale dev and tale deploy. The deploy rule is lib/deployment/tag-automation-protocol.ts:58-61: requireRuntime(/^[a-z][a-z0-9-]{0,62}$/.test(project), 'Invalid deployment project.') in tagDeploymentProtocol. That runs at lib/actions/deploy.ts:233-236 and :367, and at lib/actions/rollback.ts:171 and :280. requireRuntime throws preconditionError(message) with no next step (lib/deployment/runtime-model.ts:182) For ~/2024-site, tale dev works, but every deploy, the first included, stops with "Invalid deployment project." and exit code 3. tale rollback stops the same way. The message names neither the rule nor the fix

Notes, all at 29e9445:

  • The refusal comes late. lib/actions/run-deploy.ts has already run ensureDocker (:68), ensureEnv (:73), ensureProductionDomain (:95), the preflight (:101) and the cutover check (:116). At deploy.ts:233 the check runs inside the deploy lock (withLock, :226).
  • Relaxing only tag-automation-protocol.ts:59 is not enough. Once the project has a database (:67-68), bundledBackendIdentity checks the project and its -blue/-green names (:69-70, :81-82) against a second rule: lib/deployment/automation-protocol.ts:171 projects.every((project) => /^[a-z][a-z0-9-]{0,68}$/.test(project)),, refusing with "Invalid backend custody projects." (:172). The same check runs from lib/deployment/tag-automation-cutover.ts:105.
  • Found while verifying, not in bug(cli): digit-led project names can never deploy, --host rewrites .env even on --dry-run, and the Windows installer closes the session on error #4839: managed deployments have the same split. lib/deployment/model.ts:60 const project = z.string().regex(/^[a-z0-9][a-z0-9-]{0,39}(?![\s\S])/); allows a leading digit for composeProject (:132), and lib/deployment/runtime-apply.ts:279 accepts it. Once the project has state (:1071), checkInstalledProtocol passes it to bundledBackendIdentity (:1077-1080, :1092), which refuses it.
  • generate-project-id.ts has no test file.

Expected

  • Generate IDs that satisfy the deploy rule (prefix a letter when the folder starts with a digit), or accept the init pattern at deploy. Either way, the refusal names the rule and the fix.
  • Note for the implementer, not a decision: an existing digit-led project already has tale dev containers and volumes under its ID, so renaming IDs would orphan them. lib/actions/init.ts:243-244 keeps an existing ID on reinit for that reason: "preserve the existing project id and createdAt so Docker volumes/containers keyed on the id remain valid."

Regression: a deploy-path unit test with project ID 2024-site-abc123. Extend lib/deployment/automation-protocol.test.ts, which already calls tagDeploymentProtocol('tale', false, noState) at :188, with a fresh case and a case with an existing database, so that the second rule at automation-protocol.ts:171 runs too. lib/actions/rollback.test.ts drives deploy() and rollback() with setProjectId('tale') (:25) and can take the same ID. At 29e9445 both cases throw "Invalid deployment project." at tag-automation-protocol.ts:59.

Severity and owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions