Skip to content

Ask for a template's required secrets when installing it - #354

Merged
tnkuehne merged 3 commits into
feat/required-secrets-deployfrom
feat/required-secrets-install
Nov 23, 2026
Merged

tnkuehne merged 3 commits into
feat/required-secrets-deployfrom
feat/required-secrets-install

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A template whose code requires secrets cannot be installed in one step: the install deploys before anyone can set the secrets, so the deployment fails. The template page, CLI and API also do not say which secrets a template needs.

Change

Template installs take the values of the required secrets.

  • The install checks before building that every secret the template's wrangler.jsonc requires has a value, and that no other secret is given.
  • The values are saved only together with the app's first deployment, with the same authorization and binding limit as a secret edit. On an agent installation, the upload transaction accepts the deployment and saves them under the app lock. On Cloudflare, the deployment command carries the encrypted values and claims the first deployment; recording the accepted deployment saves them in the same transaction, and the operation history keeps the command without them.
  • If another deployment of the app is accepted first, the install fails and saves nothing, so the values only ever reach the template's own code.
  • The API takes them as secrets in the install request. widefleet catalog templates install ID --secret-file NAME=PATH reads each value from a file, as widefleet secret put --file does, and sends secrets only when given.

The template detail lists requiredSecrets. widefleet catalog templates show prints them for agents.

The template page asks for each value.

  • A password field per secret, labeled with its name. Install is enabled once every field is filled.
  • Installing requires the existing permission to create apps. The installer owns the new app and can manage its secrets, so no member sees the form without being able to submit it.

The secret status reports what the deployed code requires.

  • required lists the secrets of the latest accepted deployment's version, in Cloudflare's acceptance order on Cloudflare.
  • The Secrets page marks set ones as Required and lists unset ones as Missing, with Set value, which fills in the name and focuses the value field.
  • widefleet secret list prints the missing names.

Screenshots

Gmail with its two required secrets (declared in #355), 1280 px, light.

Before After
Template page before Template page after
Template page: Install only Template page: one field per required secret
Secrets page with one secret before Secrets page with a missing secret after
Secrets with only GOOGLE_CLIENT_ID set The other one is listed as missing; Set value filled in its name
Secrets page with both secrets before Secrets page with both secrets after
Both secrets set Both marked as required

Filled form: 1280 light. Narrow and dark: template 390 (before), missing 390 (before), required 390 (before), template 1280 dark (before), missing 1280 dark (before), required 1280 dark (before).

The after shot of the missing secret shows Skip to content because the keyboard focus followed the previous action. The before Secrets page shows two deployments because saving each secret redeployed the installed app.

Checked: desktop and 390 px in light and dark without horizontal scrolling, Install disabled until every value is filled, the install through to the Secrets page, removing a required secret and setting it again with Set value.
Not checked visually: an install whose template changed its required secrets after the page loaded (the server rejects it and lists the missing names), a secret name long enough to wrap, and the pages on a Cloudflare installation.

Tests

  • Integration tests: the template detail lists the secrets; installs without a value or with an extra secret fail before building; members without the create permission are refused; the values are saved and the deployed version records its list; removing one leaves it in required and out of names.
  • A template's Wrangler parsing, the API listing with wrangler.json, and the CLI request body and --secret-file errors (RUN_CLI_TESTS=1).
  • The browser test that installs Gmail with both values and checks the Secrets page is in Require the OAuth client secrets in templates without a managed client #355, with the template that requires them.
  • Cloudflare: registration saves the secrets once across request and Workflow races, a deployment accepted earlier rejects the install without saving anything, and the status follows acceptance order. A workerd test serves the install's secret to its own code and none to other code accepted first.
  • Ran pnpm check, the unit and integration suites, the CLI Rust tests and the Cloudflare suite (RUN_CLOUDFLARE_TESTS=1).
  • Not run: the container runtime suites.

Stack: #352 → #353 → #354 (this PR) → #355. The docs follow in #356.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; both previous findings are fixed and no new blocking issue was found.

Summary

Adds required secrets to template details and accepts their values during installation.

  • Template details list the secret names needed to install them.
  • Template installs collect required values and save them with the first deployment.
  • Secret status shows which names the deployed code requires.

Both previous findings are addressed. No new actionable issues were found. Tests and browser checks were not run during this review.

Diagram

sequenceDiagram
  actor Installer
  participant Install
  participant Builder
  participant Publish
  participant Cloudflare
  participant Database
  Installer->>Install: Required secret values
  Install->>Install: Check missing and extra names
  Install->>Builder: Build template sources
  Builder-->>Install: Worker and metadata
  Install->>Publish: Worker and encrypted values
  Publish->>Cloudflare: First-deployment command
  Cloudflare->>Database: Lock app and check deployment history
  alt App has no deployment
    Cloudflare->>Database: Save values and record deployment together
  else Another deployment exists
    Cloudflare-->>Installer: Reject without saving values
  end
Loading

Reviews (2) · Last reviewed commit: "Report the required secrets of the deplo..." · Reviewed by Greptile

A template whose wrangler.jsonc requires secrets is installed with their
values. The install checks before building that every required value and
no other is provided. The values are saved with the app's first
deployment, under the same app lock and with the same authorization and
limits as a secret edit, so they never reach a deployment that someone
else made while the template was building.

- The template detail lists requiredSecrets, which catalog templates
  show prints.
- The template page asks for each value in a password field and enables
  Install once all are filled.
- widefleet catalog templates install reads values with
  --secret-file NAME=PATH.
- The secret status reports the secrets the latest deployment requires.
  The Secrets page lists unset ones as missing with a shortcut to set
  them and marks set ones as required; widefleet secret list prints the
  missing names.
On Cloudflare a deployment is accepted after the upload transaction, so
saving the install's secrets there let another deployment of the draft
app, prepared meanwhile, receive them, and left them saved when
Cloudflare rejected the install.

The hosted deployment command now carries the encrypted values and
claims the app's first deployment. Recording the accepted deployment
saves them under the app lock, in the same transaction, and a deployment
recorded earlier rejects the install without saving anything. The
operation history keeps the command without the values. Agent
installations keep saving them in the transaction that accepts the
deployment.
Cloudflare can accept an older request after a newer one, so request
times do not order hosted deployments. The secret status now follows
the order in which deployments were accepted, as secret refreshes do,
and request times where there is none.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

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 65b93e0 Nov 23 2026, 05:54 PM

@tnkuehne
tnkuehne force-pushed the feat/required-secrets-install branch from e210dae to 65b93e0 Compare November 23, 2026 17:53
@tnkuehne
tnkuehne merged commit 395d780 into main Nov 23, 2026
25 of 27 checks passed
@tnkuehne
tnkuehne deleted the feat/required-secrets-install branch November 23, 2026 19:45
tnkuehne added a commit that referenced this pull request Nov 23, 2026
## Problem

Wrangler's `secrets.required` declares the secrets a Worker cannot run
without. Widefleet rejects unknown Wrangler keys, so a project that uses
the key cannot be deployed, and a deployment cannot record which secrets
its code needs.

## Change

**`widefleet deploy` and the template builder accept
`secrets.required`.**
- The format follows [Cloudflare's configuration
reference](https://developers.cloudflare.com/workers/wrangler/configuration/):
`"secrets": { "required": ["API_KEY"] }`.
- Names follow the contract's rules: valid secret names, without the
reserved `WIDEFLEET_` prefix or `__proto__`, unique, at most 128, and
different from every binding and variable, including the `ASSETS`
binding every deployment gets. The CLI and the builder report a mistake
before building.

**Template installs validate the build before creating the app.** A
template whose build the upload would reject now fails without leaving
an app behind.

**Each deployed version carries its list.**
- The deployment metadata stores it as `required_secrets`, so every
stored version, including one a rollback selects, keeps its own list.
- The control plane validates the list again. Runtimes do not receive
it.

The next PRs in this stack check the list when deploying (#353), ask for
the values when installing a template (#354), and declare the list in
the templates that need their organization's OAuth client (#355).

## Tests

- CLI unit test for parsing and every validation rule, including
`__proto__`, 129 names and `ASSETS` without an `assets` key.
- Builder test for the metadata it produces and its validation errors,
with the same cases (`RUN_BUILDER_TESTS=1`).
- Integration test: a template build with an undeployable list fails
before the app exists.
- Contract tests for the metadata, including that runtimes do not
receive the list.
- Ran `pnpm check`, the unit and integration suites, `cargo clippy
--workspace` and the CLI Rust tests.

Stack: #352 (this PR) → #353 → #354 → #355. The docs follow in #356.


<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=116868847&amp;sig=8186589490fcb6f27be9c10c3a9940bc27064ec179368c3f1891dcb21edb80df"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F352&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> This PR appears safe to merge; both
previous findings are fixed and no new actionable issues were found.

<details open><summary><h3>Summary</h3></summary>

Carries Wrangler's `secrets.required` into each deployment as
`required_secrets`, while keeping it out of runtime metadata.

- CLI deployments carry Wrangler's required secret names into their
metadata.
- Template builds carry Wrangler's required secret names into bundle
metadata.
- The control plane keeps required secret names with each version and
leaves them out of runtime metadata.
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (2) · Last reviewed commit: ["Validate a template&#39;s
build before
creat..."](75571e6)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Nov 23, 2026
## Problem

A version that declares required secrets still deploys when the app does
not have them, so the app starts without its credentials.

## Change

**Deployments and rollbacks fail while the app lacks a secret the
version requires.**
- The error lists every missing name, as `wrangler deploy` does: `The
following required secrets have not been set: API_KEY, API_SECRET.` It
points to the app's Secrets page and `widefleet secret put`.
- The check runs where every deployment is queued: CLI and API uploads,
template installs, previews and rollbacks, for agent and Cloudflare
executions alike.
- A rollback checks the list of the version it selects.

**Secret edits keep working.**
- Changing or deleting a secret redeploys the selected code without the
check, so a required secret can be deleted, as Cloudflare allows. The
app's code reports its missing setup until the secret is set again.

**Differences from Wrangler.**
- `widefleet deploy` creates a new app before uploading, so the first
deployment of a new app fails after the app exists. Set its secrets and
deploy again, or create it first with `widefleet create`. Wrangler fails
before creating the Worker.
- Previews are separate apps with their own secrets, so a preview needs
the required secrets set on it.

## Tests

- Integration test: a deployment without both secrets lists both, then
the remaining one; it succeeds once both are set; deleting a required
secret is allowed; a rollback to the version is rejected through the API
with the missing name until the secret is set again.
- Ran `pnpm check` and the unit and integration suites.
- Not run: the container runtime suites. The Cloudflare suite ran on
#354, which includes this change.

Stack: #352 → #353 (this PR) → #354 → #355. The docs follow in #356.


<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=116868905&amp;sig=0a90f4561e35c8039a6c3e0790389f3ed107d0ea2df43d6a05233adfa0005d11"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F353&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge, with
template secret input supplied by dependent PR #354.

<details open><summary><h3>Summary</h3></summary>

Deployments and rollbacks now reject versions whose required secrets are
missing. Errors list the missing names and explain where to set them.

- Deployments and rollbacks stop when their selected version needs
missing secrets.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Upload or rollback] --> B[Read selected version]
  B --> C{Required secrets present?}
  C -->|No| D[Return missing names]
  C -->|Yes| E[Queue agent or hosted deployment]
  F[Secret edit] --> G[Redeploy selected code without required-secret check]
  G --> E
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (2) · Last reviewed commit: ["Reject deployments and
rollbacks
without..."](39782a2)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Nov 23, 2026
#355)

## Problem

The Gmail, Google Calendar, Google Sheets, Google Drive, WHOOP and
Strava templates cannot connect accounts without the organization's own
OAuth client, but nothing asks for it when installing. The app deploys
and reports `setup_required` until an administrator finds the Secrets
page.

## Change

**These templates require their OAuth client.**
- Each `wrangler.jsonc` lists the client ID and secret under
`secrets.required`: `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`,
`WHOOP_CLIENT_ID` and `WHOOP_CLIENT_SECRET`, `STRAVA_CLIENT_ID` and
`STRAVA_CLIENT_SECRET`.
- Installing from the template page or the CLI asks for the values, and
deploying without them fails with their names.
- Templates with a managed client (Outlook, OneDrive, Excel, Teams,
GitHub, Linear) and Garmin Connect, whose users bring their own keys,
keep optional secrets.

**The templates still handle a deleted secret.** They keep reporting
`setup_required`, and their connect page now asks the administrator to
set the secrets on the app's Secrets page.

**`template.md` follows the new order.**
- Deploying a copy creates the app, sets both secrets with `widefleet
secret put` and then runs `widefleet deploy`.
- The setup steps say that installs ask for the values, and that the
provider's redirect URL or callback domain can be added once the app's
URL is known.

### Screenshots

The Gmail template page now asks for both values before installing (1280
px, light):

<img
src="https://gist.githubusercontent.com/tnkuehne/0ac26ce32c2037ae89a7e23f9f9ae198/raw/6742d313e346ee88719a8ff56f49044b2a232540/compare-template-install-1280-light.png"
alt="Gmail template page before and after" width="840">

The Secrets page shots are in #354. Not checked visually: the other five
template pages, which use the same form.

## Tests

- A browser test installs Gmail from its page, checks that Install waits
for both password fields, that both secrets are saved encrypted, and
that the Secrets page marks them as required. It removes one, checks
that it is listed as missing, and sets it again through **Set value**.
- The template install integration tests install Gmail with its secrets,
and check that an install raced by another deployment leaves that app's
secrets unchanged.
- Ran `pnpm check`, the unit and integration suites, each changed
template's tests and the browser test.
- Not run: the container runtime suites. The Cloudflare suite ran on
#354.

Stack: #352 → #353 → #354 → #355 (this PR). The docs follow in #356.




<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=116868985&amp;sig=77c5cca5d263520146b5239cfce7e6cc935679b4d72cae0f37f1ef1cc9cd1d08"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F355&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge; no new
actionable issues were found.

<details open><summary><h3>Summary</h3></summary>

Requires OAuth client secrets for Gmail, Google Calendar, Google Drive,
Google Sheets, WHOOP and Strava.
- Six OAuth templates ask for provider credentials before deployment.
- Connection pages tell admins where to restore missing OAuth keys.
- Setup guides put app creation and OAuth keys before deployment.
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (3) · Last reviewed commit: ["Find the setup prompt in its
own
section..."](48691a1)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
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