Skip to content

Handle references in apify env pull, diff, and push #1649

Backlog

Description

@DaveHanns

apify env pull, diff, and push move env vars between a local .env file and an Actor version. .env holds names and values only, so it can't hold a reference: a version env var that points to a shared variable of the account in place of a value. Without this change, the three commands treat a reference as a plain variable with an empty value: pull writes an empty value over the local one, diff reports a difference, and push replaces the reference with the value from .env, stored as plain.

Scope

  • Read the type of each referenced shared variable, and the value of a plain one, from the list of the store (the shared variables of the account). Do it only when the Actor's owner is the account that the CLI is logged in to: the list returns the store of that account, and a reference points to the store of the Actor's owner. For any other Actor, and for a reference whose variable isn't in the list, the commands know only the name of the env var and the name of the shared variable.
  • Write the value of a plain shared variable and an empty value for a shared secret in apify env pull. A reference with a known plain value is handled like a plain variable: the value is written, even over a different local value. Every other reference is handled like a secret: the key is written with an empty value, and a value that .env already has stays.
  • Write no shared value for a caller who can't read it. The list of the store returns no values to an organization member who can edit Actors but lacks the permission to manage the store (proposed). For such a member, pull writes every reference like a reference to a secret.
  • Treat a reference like any other variable in apify env diff. Compare it by value when the shared value is known, and by name only when it isn't, as for a secret. A reference never counts as a difference only because it's a reference.
  • Protect references in apify env push. Never replace a reference with a value from .env unless the diff shows that replacement. The diff is the list of changes that the command prints before it asks. Proposed: push doesn't write over a reference at all. The diff lists each reference as kept, with the name of its shared variable, and marks the ones whose known value differs from .env. A user who wants the env var to hold a value of its own runs apify env set <name>. The reason: a local run needs a value for a referenced secret in .env, and push would otherwise replace the reference each time. With --prune, a reference whose name isn't in .env is deleted like any other variable, and the diff marks it as a reference.
  • Name the shared variable next to each reference in the output of the three commands, also with --json. Print names only, never a value.
  • Describe the behavior in the env var guide (docs/vars.md).

This can ship as two pull requests: pull and diff first, then push.

Done when

  • Local tests (test/local/commands/env/) cover the three commands on a version with a reference to a plain variable, to a secret, and to a variable that the list of the store doesn't return.
  • A test runs apify env pull, adds a local value for a referenced secret to .env, and runs apify env push --yes. The reference is still in place.
  • A test covers an Actor of another account: the commands don't read the store.

Depends on

Activity

  1. added
    t-builders
    on Nov 30, 2026
  2. added theissue type on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-builders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions