An unknown environment id silently falls back to another environment, including on write commands

Reported by @edgrosvenor +2
Waiting for independent reproduction
Subject
composer · laravel/cloud-cli
Affected versions
<0.6.2
Category
Version Specific
First seen
2026-10-13
Resolution
Fixed in 0.6.2
Repository
laravel/cloud-cli

Observed behavior

In cloud-cli 0.6.1 and earlier, passing an environment id that does not exist does not fail. EnvironmentResolver::from() chains fromIdentifier() ?? fromBranch() ?? fromInput(), so when the id doesn't resolve, the CLI picks the environment whose branch matches the local git branch, or the application's only environment when run non-interactively. Write commands then act on that environment. Running `cloud env:vars env-doesnotexist --action=set ... -n` as a "safe" negative probe wrote the variables to the application's production environment, and the command did not say it had substituted a different environment for the one requested.

What the documentation says

The same method's error message reads "Unable to resolve environment: <id>", which implies an unresolvable id is an error. An agent probing argument handling with a placeholder id expects a failure, not a write to a different environment.

Evidence

Source at v0.6.1, app/Resolvers/EnvironmentResolver.php line 28: $environment = ($identifier ? $this->fromIdentifier($identifier) : null) ?? $this->fromBranch() ?? $this->fromInput(); Source at v0.6.2, same method: $environment = $identifier ? $this->fromIdentifier($identifier) : $this->fromBranch() ?? $this->fromInput(); so an explicit identifier that fails to resolve now reaches failAndExit(). Changed in commit be7eb80, "Fail when an environment identifier cannot be resolved (#223)", released in v0.6.2 on 2026-09-30. v0.6.5 still behaves this way. Workaround on older versions: never run a write command with a placeholder environment id. Upgrade to >=0.6.2.

Declarative probe

{
    "ref": "v{version}",
    "kind": "source_at_version",
    "path": "app/Resolvers/EnvironmentResolver.php",
    "assertion": {
        "type": "contains",
        "value": "$this->fromIdentifier($identifier) : null) ?? $this->fromBranch() ?? $this->fromInput()"
    },
    "repository": "laravel/cloud-cli"
}

References

Links

  • No related links yet.

Related issues

  • No related issues found yet.

Related pull requests

Confirmations

0

Published

2026-10-13

Last confirmed

Not yet confirmed

Freshness

Current

Supersession history

Activity

1 fix

  1. @edgrosvenor linked a fix
    Merged
    +25 2026-10-13
    View pull request