You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2026. It is now read-only.
Repository navigation
Attach bucket keys with environment:update --bucket-keys - #295
Adds --bucket-keys to environment:update, so object storage can be attached to an environment from the CLI. Until now that was dashboard-only, which is the gap behind #115.
The API attaches buckets through filesystem_keys on PATCH /environments/{environment}. UpdateEnvironmentRequestData already carried the field; no command set it.
cloud environment:update production --bucket-keys=fk-1:local:default,fk-2:public --json -n
Format: comma-separated KEY_ID:DISK entries, with :default on at most one. This matches how --allowed-origins takes a list, and it allows the private default disk plus a public disk that the bundled skill recommends.
Replaces the whole list, because the API does. An empty string detaches every bucket.
Needs --force to replace buckets that are already attached. The command reads the environment's buckets relationship first. This is the confirmation Bucket deletion blocked by attached keys — no CLI path to detach or cascade delete #115 said was impossible, because GET /environments/{id} didn't return attachments; it now does with include=buckets. The API still doesn't say which key or disk an attached bucket uses, so the command can't merge into the existing list.
Interactive runs choose a bucket, then a key, then the disk name and whether it's the default, and can repeat for more buckets.
environment:get now reports bucketIds, because buckets joins the default environment includes.
Updates the skill (SKILL.md and the new-app checklist) with the command.
Tests: 8 new cases in EnvironmentRelationshipsTest:
attaching several keys;
refusing to replace without --force, and replacing with it;
detaching all;
rejecting malformed entries and two default disks;
reading bucketIds.
phpstan and pint pass. The full suite has the same 8 failures with or without this change (ContextDetectorTest, RepoConfigTest, UsageCommandTest); they come from agent environment variables in the environment I ran it in.
The API attaches object storage to an environment through filesystem_keys
on PATCH /environments/{environment}, but no command set it, so buckets
could only be attached from the dashboard.
--bucket-keys takes comma-separated KEY_ID:DISK entries, with :default on
at most one. The API replaces the whole list, so the option names every
bucket the environment should end up with, an empty string detaches them
all, and replacing buckets that are already attached needs --force.
Environments now include their buckets, so environment:get reports
bucketIds.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1de2b-3aa5-7684-a19c-87386ad7c591
Co-authored-by: Ed Grosvenor <ed@artisan.build>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
API validation errors for filesystem_keys do not match the registered bucket_keys field, causing prompt-driven updates to resend invalid values and exit instead of reopening the selector.
Adds bucket attachment management to environment:update, providing a CLI path to attach or detach buckets and supporting the cleanup workflow described in #115.
Changes:
Adds --bucket-keys and an interactive selector, with confirmation before replacing existing attachments.
Includes attached bucket IDs in environment responses.
Adds tests and updates deployment guidance.
File
Description
tests/Feature/EnvironmentRelationshipsTest.php
Tests attachments, replacement safeguards, detachment, validation, and bucket IDs.
skills/deploying-to-cloud/SKILL.md
Documents bucket attachment syntax and replacement behavior.
The form field was named bucket_keys, so a 422 on filesystem_keys.0.disk
matched no field: an interactive update resent the same list and exited
instead of reopening the bucket selector. Name the field after the API
field and keep --bucket-keys as the option.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1de2b-3aa5-7684-a19c-87386ad7c591
Co-authored-by: Ed Grosvenor <ed@artisan.build>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Disk input is not validated before serialization, allowing commas and colons to alter attachment selections, unexpectedly set a default disk, or abort the command.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Reject serialization delimiters in disk input
app/Commands/EnvironmentUpdate.php:647
The disk prompt accepts the delimiters used to serialize the list. For example, entering local:default and answering “No” to the default-disk question still produces a default disk after parsing; entering my,disk instead aborts the command in parseBucketKeys() rather than allowing correction. Validate the disk input before serialization so commas and colons cannot change the meaning of the selected attachments.
The prompt accepted ':' and ',', the characters bucket entries are joined
with, so a disk named local:default became the default disk even after
answering no, and my,disk aborted the command. Check the name against the
API's own pattern, which excludes both.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1de2b-3aa5-7684-a19c-87386ad7c591
Co-authored-by: Ed Grosvenor <ed@artisan.build>
Re Copilot's "Reject serialization delimiters in disk input": fixed in 6d54f9d. The interactive disk prompt now validates against the API's own rule for disk names (^[A-Za-z0-9 _-]+$, at most 40 characters), which rules out : and ,. Without it, local:default became the default disk even after answering no, and my,disk aborted the command. A new test types local:default, checks that the prompt refuses it, and checks that the result is local, not the default disk. It failed before the change. The 422 retry test now uses a name that passes local validation, since my.disk is rejected before reaching the API.
Context on #115: #148 added the bucket argument to bucket-key:delete and bucket-key:update, which was the side issue at the end of #115. The main ask, attaching and detaching a bucket key from the CLI, is still open on main, and this PR covers it.
#115's main objection was that GET /environments/{id} didn't show which buckets were attached. That's no longer true: include=buckets now returns them. This PR uses it to require --force before replacing buckets that are already attached, and environment:update --bucket-keys= (empty) detaches them all, so a bucket can be deleted from the CLI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
--bucket-keystoenvironment:update, so object storage can be attached to an environment from the CLI. Until now that was dashboard-only, which is the gap behind #115.The API attaches buckets through
filesystem_keysonPATCH /environments/{environment}.UpdateEnvironmentRequestDataalready carried the field; no command set it.KEY_ID:DISKentries, with:defaulton at most one. This matches how--allowed-originstakes a list, and it allows the private default disk plus apublicdisk that the bundled skill recommends.--forceto replace buckets that are already attached. The command reads the environment'sbucketsrelationship first. This is the confirmation Bucket deletion blocked by attached keys — no CLI path to detach or cascade delete #115 said was impossible, becauseGET /environments/{id}didn't return attachments; it now does withinclude=buckets. The API still doesn't say which key or disk an attached bucket uses, so the command can't merge into the existing list.environment:getnow reportsbucketIds, becausebucketsjoins the default environment includes.SKILL.mdand the new-app checklist) with the command.Tests: 8 new cases in
EnvironmentRelationshipsTest:--force, and replacing with it;bucketIds.phpstanandpintpass. The full suite has the same 8 failures with or without this change (ContextDetectorTest,RepoConfigTest,UsageCommandTest); they come from agent environment variables in the environment I ran it in.Not tested against a live Cloud organization.