Skip to content

Stop copying app secret values onto agent jobs - #382

Merged
tnkuehne merged 1 commit into
mainfrom
secrets/job-secret-copies
Nov 25, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
secrets/job-secret-copies

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claiming an agent job copied every encrypted secret of the app into job.app_secrets. The copy stayed until the app was removed, so each claim added another one, and a deleted secret survived in earlier jobs.

What changes

  • Claim stores only { appId, revision } on the job.
  • Packages reads the app's current secrets and revision inside the lease transaction, decrypts them and returns the same appSecrets object as before. It replaces the job's revision with the one it delivered.
  • Completion still applies the job's revision to applied_secret_revision. When secrets change between claim and packages, the agent receives the newer revision and completion confirms that one. Jobs that never request packages (migrations, workflows, delete, and configure without a deployment) keep today's behavior.
  • Migration 0043_job_secret_revisions removes values from existing job.app_secrets rows and keeps appId and revision.

The packages wire contract and the agent are unchanged.

Upgrade notes

Self-hosted installations apply the migration when the new control plane starts. Hosted installations use Cloudflare execution, which accepts no agent jobs. An earlier control plane reads secret values from the job row. If one is run against the migrated database, the packages request fails for jobs that are still running, and those deployments must be retried.

Verification

  • pnpm check
  • pnpm exec vitest run for tests/platform.integration.test.ts (38 tests), the new tests/job-secret-revisions-migration.integration.test.ts, and the job-related required-secrets, app-removal, template-installs and migration integration tests: 59 passed, against local PostgreSQL and RustFS with synthetic data.
  • The new platform test fails on the previous jobs.ts. It covers:
    • no values on any job row
    • the unchanged packages response
    • a secret change between claim and packages, which is delivered and recorded
    • a new attempt after lease expiry, where the stale lease's packages request and completion are rejected
    • a job completed without packages, which applies its claim revision
  • Not run locally: the Rust runtime deployment suite, which CI runs.

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

The PR appears safe to merge with the documented upgrade restriction.

Summary

Stops storing encrypted secret values on agent jobs.

  • Agent jobs keep secret values out of their saved records.

No actionable issues found.

Acknowledged by tnkuehne: older control planes cannot serve packages from migrated job rows; affected deployments must be retried.

Diagram

sequenceDiagram
  participant Agent
  participant Control as Control plane
  participant Job as Job row
  participant App as App row
  Agent->>Control: Claim job
  Control->>App: Read secret revision
  Control->>Job: Store app ID and revision
  Agent->>Control: Request packages
  Control->>Job: Check and lock lease
  Control->>App: Read current secrets and revision
  Control->>Job: Store delivered revision
  Control-->>Agent: Return decrypted secrets and runtime
  Agent->>Control: Complete job
  Control->>Job: Check lease and read revision
  Control->>App: Mark revision applied on success
Loading

Reviews (1) · Last reviewed commit: "Stop copying app secret values onto agen..." · Reviewed by Greptile

A claim copied every encrypted secret of the app into job.app_secrets,
and the copy stayed until the app was removed. A claim now stores only
the app's secret revision. The packages request reads and decrypts the
app's current secrets, returns the same response as before, and records
the revision it delivered, which completion applies.

A migration removes the stored values from existing jobs and keeps
their app and revision.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs d18e82e Nov 25 2026, 10:10 AM

@tnkuehne
tnkuehne merged commit 342443f into main Nov 25, 2026
18 checks passed
@tnkuehne
tnkuehne deleted the secrets/job-secret-copies branch November 25, 2026 10:41
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.

1 participant