Repository navigation
Open
Labels
t-buildersIssues owned by the Builders team.
Description
With this issue, the apify env commands manage the shared store: the list of shared variables of an account, which Actor versions reference from their env vars. The store changes six commands (ls, set, rm, pull, diff, and push) and adds one (link). This issue covers ls, set, and rm with a --store flag, and the commands for references follow in #1648 and #1649.
Scope
- Add
--storetoapify env ls,set, andrm. With it, the command manages the account's shared variables instead of the Actor's. Proposed name:--store, because a "global" flag can be read as either per Actor or per organization. The store Epic lists the CLI naming as an open decision. Close it before this issue starts. - Work on the account that the CLI is logged in to. The CLI logs in with an OAuth access token by default, so the store has to accept such a token (apify/apify-core#32548). A command with
--storeneeds no Actor: it doesn't read.actor/actor.json, and--dir,--actor, and--versioncan't be combined with it. - List each shared variable's name, type (secret or plain), and description with
apify env ls --store, and the value of a plain variable. A secret's value stays hidden, as inapify env ls. The--jsonoutput has the same fields. - Print what the API returns to the caller. An organization member who can edit Actors but lacks the permission to manage the store gets names, types, and descriptions, and no values, not even of plain variables (proposed). For such a member,
ls --storeprints the list without values, andset --storeandrm --storefail with the API's error. A scoped API token has no access to the store in the first version (proposed). - Create a shared variable with
apify env set <name> --store, or update the value of an existing one. The value comes from a prompt or standard input, never from an argument, as inapify env set. Proposed: a new shared variable is a secret unless--no-secretis passed, the same default as in Console, the API, and the MCP tools. An existing variable keeps its type unless--secretor--no-secretis passed. Without--store,apify env setcreates a plain variable unless--secretis passed, so the help of the flag has to name both defaults. - Delete a shared variable with
apify env rm <name> --store. The command asks for confirmation and fails on a name that doesn't exist, asapify env rmdoes. - Make
rm --storeon a referenced variable fail with the list of Actors, unless--forceis passed. The API refuses such a delete, and the list comes from the usage endpoint: each Actor with its versions and the env var's name in each version. Show the first page of Actors and their total number. The message says how to go on: remove the references and rebuild those Actors, or pass--force. - Send
force=truewith--force. The command then shows the same list as a warning, says that runs of those Actors fail to start once the variable is gone, and deletes the variable.--yesskips only the confirmation prompt and doesn't replace--force. - Print no rebuild reminder (
printRebuildReminderinsrc/lib/env-vars/output.ts) afterset --storeandrm --store: it's for changes to an Actor version. Afterset --store, say that runs read the value when they start, so the change needs no rebuild. When the command replaced an existing value, add that the change reaches every Actor that references the variable and that the previous value isn't kept. - Describe
--storein the env var guide (docs/vars.md) and regenerate the command reference (docs/reference.md).
This can ship as two pull requests: ls --store first, then set --store and rm --store.
Rollout
The CLI can be released with --store before the store is released to every account (apify/apify-core#33725). Until then, the API refuses an account without the feature flag of the store, and the commands print that error.
Done when
- Local tests (
test/local/commands/env/) cover the three commands with--store: a new variable is a secret by default, a list without values prints no values, andrm --storeon a referenced variable fails with the list of Actors and deletes the variable with--force. - The output of
set --storenever contains the value, not even in an error.
Depends on
apify env ls(Add theapify envnamespace andapify env ls#1570)apify env setandapify env rm(Addapify env setandapify env rm#1571)- A release of the JavaScript client with shared env vars (Support shared env vars in the JavaScript client apify-client-js#1209), with
usageand theforceoption ofdelete
Metadata
Metadata
Assignees
Labels
t-buildersIssues owned by the Builders team.
Activity
[-]Support the shared store in `apify env`[/-][+]Manage the shared store with `apify env`[/+]