Skip to content

fix: set-remote with project ID outside a project root#53

Merged
miguelsanchez-upsun merged 3 commits intomainfrom
fix/set-remote-without-project-root
Apr 28, 2026
Merged

fix: set-remote with project ID outside a project root#53
miguelsanchez-upsun merged 3 commits intomainfrom
fix/set-remote-without-project-root

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

Summary

upsun set-remote PROJECT_ID failed with RootNotFoundException when run in a fresh Git checkout (no .platform/local/project.yaml yet) — the typical CI / pipelines case.

The unified Selector::getSelection() reads project IDs from the --project option only, so the positional project argument on set-remote was silently dropped. The selector then fell back to getCurrentProject(), found no project root, and threw — even though the user had supplied the ID. The pre-5.x CommandBase::selectProject(\$projectId) call took the argument directly, which is what this restores.

Changes

  • legacy/src/Command/Project/ProjectSetRemoteCommand.php: when a project ID argument is given, look it up via Api::getProject() directly and skip getSelection(). Fall back to getSelection() only when no argument is given (interactive prompt or env-var path).
  • integration-tests/set_remote_test.go: covers five paths — the regression case (project ID in a fresh git repo), unknown project ID, outside a git repo, unset with nothing mapped, and no-arg in non-interactive mode.
  • integration-tests/tests.go: adds a dir field on cmdFactory so a test can run the CLI inside an ad-hoc git repo.

The regression subtest reproduces the bug verbatim (Selector.php line 295: Could not determine the current project) when run against the unfixed PHP and passes with the fix.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 28, 2026 09:29
pjcdawkins and others added 3 commits April 28, 2026 11:16
The unified Selector::getSelection() reads project IDs from the --project
option only, so the ProjectSetRemoteCommand argument was discarded and the
selector then tried to detect the current project from disk. In a fresh
checkout (e.g. CI runners) that produced a RootNotFoundException even when
the project ID was supplied as an argument.

Bypass getSelection() when an argument is given and load the project
directly via the API, matching the pre-5.x behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Api service ignores the project host when an api.base_url is
configured (always the case for Upsun), so passing it through from
Identifier::identify() is dead weight.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an integration test exercising the set-remote command across the
main code paths: the regression case with a project ID in a fresh git
checkout (which previously failed with RootNotFoundException), an
unknown project ID, running outside a git repository, an unset call
with nothing mapped, and the non-interactive case with no argument.

Adds a 'dir' field on cmdFactory so commands can be run from a
specific working directory rather than the default temp directory.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pjcdawkins pjcdawkins force-pushed the fix/set-remote-without-project-root branch from ef498ad to af67dff Compare April 28, 2026 10:16
@pjcdawkins pjcdawkins changed the title fix(legacy): set-remote with project ID outside a project root fix: set-remote with project ID outside a project root Apr 28, 2026
@miguelsanchez-upsun miguelsanchez-upsun merged commit 026577c into main Apr 28, 2026
4 checks passed
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.

2 participants