Skip to content

fix(cli): make deploy honour --project instead of silently ignoring it - #3507

Merged
kojiwakayama merged 3 commits into
mainfrom
fix/deploy-project-flag
Aug 9, 2026
Merged

fix(cli): make deploy honour --project instead of silently ignoring it#3507
kojiwakayama merged 3 commits into
mainfrom
fix/deploy-project-flag

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

veryfront deploy --project X accepted the flag and threw it away, resolving the project from the working directory instead:

$ deno run -A cli/main.ts deploy --project codersociety --environment production --dry-run
  › Would push source to "main", create release, and deploy to "production" for project veryfront-code

Worse than a no-op. deploy does not merely promote — it pushes the working directory as project source first. Combined with the ignored flag, one command can upload an unrelated directory into a project and promote the result. This nearly put a framework repository live on a customer's site; only the dry-run's project name caught it.

Cause

The plumbing already existed: cli/shared/deployment/deploy-project.ts:226-237 handles request.projectSlug and labels it { kind: "argument", name: "--project" }. Only parseDeployArgs' map was missing the field, so createArgParser — which copies only mapped fields — discarded it.

Naming a project now also makes the deploy promote-only. That is what stops the upload: a working directory is unrelated to a project the caller named by slug.

Dry run and apply now agree

Making the source already-pushed exposed a second problem, and it matters because the reported incident was a dry run. The dry-run branch validated the push receipt only for an ensure-pushed source, so a named project skipped the check entirely and reported a deploy that the byte-identical apply refused.

It now validates for a named project too. --skip-source-push keeps its existing dry-run behaviour — that caller has explicitly said the source is handled — so this does not tighten an unrelated path.

Test

refuses to deploy a project this directory did not push writes a valid receipt for my-project and then deploys --project other-project, so nothing but the mismatch can stop it, and nothing may be uploaded on the way.

Checked against the mutation that matters — dropping the projectSlug forwarding — and it fails. A test using the already-linked slug passes either way, which is why this one names a different project.

Both modes are covered

refuses to deploy a project this directory did not push writes a valid receipt for my-project, resolves other-project so nothing but the mismatch can refuse, and asserts the refusal by message. refuses the same mismatch in a dry run as in an apply pins the two modes together.

Each was checked in the direction that matters:

Mutation Result
drop the projectSlug forwarding fails
revert the dry-run receipt check fails
as written passes

The dry-run case took two attempts. The first passed with the fix reverted and was deleted rather than shipped; the cause was the fixture resolving only one project, so the dry run died on a lookup either way. Resolving other-project for the mismatch test removed that blocker and the case could then be written honestly.

Found via veryfront-issue-inbox#430. The promote-only behaviour change is worth a reviewer's attention: anyone who relied on deploy --project X bootstrapping the first push must now run veryfront push first.

Summary by CodeRabbit

  • New Features

    • Added support for targeting a specific project during deployment with --project/-p.
    • Added the --dir option for specifying the deployment directory.
    • Updated deployment help with project-specific examples and promotion requirements.
    • Dry-run output now identifies the selected project.
  • Bug Fixes

    • Prevented named-project deployments and dry runs from proceeding without a verified source push or with a mismatched source.

`veryfront deploy --project X` resolved the project from the working directory
and dropped the flag. Worse, deploy does not merely promote: it pushes the
working directory first, so naming a project could upload an unrelated
directory into it and promote the result. The plumbing already existed --
`deploy-project.ts` handles `request.projectSlug` and labels it
`{ kind: "argument", name: "--project" }` -- only the CLI arg map was missing
the field, so `createArgParser` discarded it.

Naming a project now also makes the deploy promote-only, which is what stops
the upload: a directory is unrelated to a project the caller named by slug.

That made dry run and apply disagree, which matters because the reported
incident was a dry run. The dry-run branch validated the push receipt only for
an `ensure-pushed` source, so a named project skipped the check and reported a
deploy the identical apply refused. It now validates for a named project too.
`--skip-source-push` keeps its existing behaviour; that caller has said the
source is handled.

The regression test names a project the directory did NOT push, which is the
incident. Checked against the mutation that matters -- dropping the projectSlug
forwarding -- and it fails, where a test using the already-linked slug passes
either way.
@kojiwakayama
kojiwakayama requested a review from kwakayama as a code owner August 9, 2026 14:04
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The deploy command now accepts --project and -p, selects the named project without pushing the working directory, validates matching push receipts, and reports project-specific dry-run details. Help text and tests cover the new behavior.

Changes

Named project deployment

Layer / File(s) Summary
Project selection and request construction
cli/commands/deploy/command.ts, cli/commands/deploy/command.test.ts, cli/commands/deploy/command-help.ts
Deploy arguments accept projectSlug. Requests use already-pushed source mode for named projects. Dry-run output includes the project slug. Help text and CLI tests cover the option.
Push-receipt validation
cli/shared/deployment/deploy-project.ts, cli/commands/deploy/command.integration.test.ts
Named-project dry runs validate pushed source. Integration tests reject missing or mismatched receipts without uploads or deployment creation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as deploy command
  participant DP as deploy-project
  participant PR as pushed-source validation
  participant DE as deployment executor
  CLI->>DP: submit projectSlug with already-pushed source mode
  DP->>PR: validate matching verified push receipt
  PR-->>DP: return receipt validation result
  alt receipt matches
    DP->>DE: create deployment
    DE-->>CLI: return deployment result
  else receipt missing or mismatched
    DP-->>CLI: return receipt error without upload or deployment
  end
Loading

Suggested reviewers: kwakayama

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making deploy honor the --project option.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deploy-project-flag

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/commands/deploy/command-help.ts`:
- Line 51: Update the help text string in the deploy command’s project option
description to replace “this directory” with “the selected project directory,”
accurately reflecting the directory used for receipt validation when --dir is
provided.

In `@cli/commands/deploy/command.integration.test.ts`:
- Around line 640-676: Update the test around deployCommand to add an
other-project fixture with its own project ID and environment so
createDeployFetchHandler resolves the target before receipt validation. Assert
the specific receipt-project mismatch error rather than any rejection, and run
equivalent assertions for both dryRun: false and dryRun: true while preserving
the no-upload verification.

In `@cli/commands/deploy/command.test.ts`:
- Line 291: Replace the hard-coded absolute projectDir value in the affected
deployment test with a relative placeholder path, preserving the existing fake
deployment executor behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c6ee2c8-f025-4cd5-8fe0-4b34550f94c6

📥 Commits

Reviewing files that changed from the base of the PR and between c8cab33 and d49d273.

📒 Files selected for processing (5)
  • cli/commands/deploy/command-help.ts
  • cli/commands/deploy/command.integration.test.ts
  • cli/commands/deploy/command.test.ts
  • cli/commands/deploy/command.ts
  • cli/shared/deployment/deploy-project.ts

Comment thread cli/commands/deploy/command-help.ts Outdated
Comment thread cli/commands/deploy/command.integration.test.ts
Comment thread cli/commands/deploy/command.test.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d49d2734de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/commands/deploy/command.test.ts Outdated
The mismatch test named a project the fixture could not resolve, so the deploy
could fail on that lookup and the assertion -- which only required some error --
would not have noticed. It now resolves `other-project`, leaving the receipt as
the only thing that can refuse, and asserts the refusal by message.

Also drops a hard-coded absolute path from the fake-executor test, which
AGENTS.md prohibits, and corrects the help note: with `--dir` the receipt is
read from the selected project directory rather than the working one.
The first attempt at this test passed with the fix reverted, so it was deleted
and the gap written into the PR description instead. The cause was the fixture,
not the idea: `other-project` did not resolve, so the dry run failed on that
lookup whether or not it validated the receipt.

Resolving that project for the mismatch test removed the blocker, so the case
can now be written honestly. Reverting the dry-run condition makes it fail --
the dry run stops validating, reports a deploy, and the assertion notices.
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 9, 2026
Merged via the queue into main with commit 4ba314f Aug 9, 2026
31 checks passed
@kojiwakayama
kojiwakayama deleted the fix/deploy-project-flag branch August 9, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant