Skip to content

fix(setup): warn when the machine user client secret is set outside its environment - #2922

Open
dqn wants to merge 1 commit into
mainfrom
feat/env-check-repository-client-secret
Open

dqn wants to merge 1 commit into
mainfrom
feat/env-check-repository-client-secret

Conversation

@dqn

@dqn dqn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

tailor setup ci env --check reported TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET set on the repository or the organization with ✔, though any workflow on any branch can read it there and the GitHub Environment's protection rules do not guard it. It now warns and prints the commands that move it onto the environment.

 Environment "stg" (branch my-app)
-  ✔ TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET (secret, set on the repository)
+  ⚠ TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET (secret, set on the repository): any workflow on any branch can read it from the repository, so the environment's protection rules do not guard it; set it on the environment and delete it from the repository

What changes

  • The client secret found on the repository or the organization, even next to a copy on the environment, used to show ✔; it now shows ⚠ with what to do, and the last line warns instead of reporting success. The exit code is unchanged.
  • The printed gh commands now also set the client secret on each environment that lacks it, telling you to reuse the value already set, and list a commented-out gh secret delete for the repository copy. An organization copy gets no command: an organization owner has to stop sharing it with the repository.
  • --json reports those scopes per entry as exposedIn.
  • Other secrets on the repository, such as the Slack bot token, and the autofix workflow's repository secrets still show ✔.
  • The docs explain the warning and how to stop it: set the same client secret on each environment, also when every target shares one machine user.

Notes

  • It warns rather than fails, with no flag to silence it: the docs still allow a repository-level client secret, and setting the same value on each environment clears the warning while keeping one shared machine user.
  • gh secret delete is commented out because a deleted secret cannot be restored, and with --environment an environment the check skipped may still read the repository copy.

…ts environment

`tailor setup ci env --check` reported TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET
set on the repository or the organization with a plain check mark, though any
workflow on any branch can read it there and the GitHub Environment's protection
rules do not guard it. It now reports it with a warning, also when the environment
sets it too, prints the gh commands that set it on the environment and a
commented-out command that deletes the repository copy, and ends with a warning
instead of the success line. The check still passes. The JSON output carries the
scopes as `exposedIn`.
@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3c97106

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tailor-platform/sdk-plugin-setup Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tailor-platform/create-sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/create-sdk@3c97106

@tailor-platform/eslint-plugin-sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/eslint-plugin-sdk@3c97106

@tailor-platform/sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk@3c97106

@tailor-platform/sdk-plugin-frontend

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-frontend@3c97106

@tailor-platform/sdk-plugin-seed

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-seed@3c97106

@tailor-platform/sdk-plugin-setup

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-setup@3c97106

@tailor-platform/sdk-plugin-tailordb-erd

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-tailordb-erd@3c97106

commit: 3c97106

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Code Metrics Report (packages/sdk)

Complexity change of this pull request: cognitive +15, cyclomatic +31
Function File Cognitive Cyclomatic
printReport > <anonymous> > <anonymous> ×3 packages/sdk-plugin-setup/src/env-check.ts:297 0 → 3 (+3) 1 → 6 (+5)
checkRequirement > <anonymous> ×2 (new) packages/sdk-plugin-setup/src/env-check.ts:52 – → 2 (+2) – → 4 (+4)
checkRequirement packages/sdk-plugin-setup/src/env-check.ts:45 4 → 6 (+2) 5 → 8 (+3)
exposureWarning (new) packages/sdk-plugin-setup/src/env-check.ts:345 – → 2 (+2) – → 3 (+3)
report packages/sdk-plugin-setup/src/env-check.ts:247 5 → 7 (+2) 5 → 7 (+2)
report > <anonymous> ×5 packages/sdk-plugin-setup/src/env-check.ts:249 1 → 2 (+1) 3 → 7 (+4)
printReport packages/sdk-plugin-setup/src/env-check.ts:284 6 → 7 (+1) 5 → 6 (+1)
statusLine packages/sdk-plugin-setup/src/env-check.ts:321 7 → 8 (+1) 8 → 9 (+1)
renderGhCommands packages/sdk-plugin-setup/src/env.ts:298 5 → 6 (+1) 8 → 9 (+1)
printReport > <anonymous> ×3 packages/sdk-plugin-setup/src/env-check.ts:295 0 → 0 (0) 2 → 3 (+1)
renderGhCommands > <anonymous> ×2 packages/sdk-plugin-setup/src/env.ts:307 8 → 8 (0) 7 → 8 (+1)

Compared with the base commit of this pull request.

main (0c17d81) #2922 (16b7e02) +/-
Coverage 89.2% 89.2% 0.0%
Code to Test Ratio 1:0.5 1:0.5 0.0
Details
  |                    | main (0c17d81) | #2922 (16b7e02) | +/-  |
  |--------------------|----------------|-----------------|------|
  | Coverage           |          89.2% |           89.2% | 0.0% |
  |   Files            |            578 |             578 |    0 |
  |   Lines            |          25815 |           25815 |    0 |
  |   Covered          |          23035 |           23035 |    0 |
  | Code to Test Ratio |          1:0.5 |           1:0.5 |  0.0 |
  |   Code             |         212577 |          212577 |    0 |
  |   Test             |         120407 |          120407 |    0 |

SDK Configure Bundle Size

main (0c17d81) #2922 (16b7e02) +/-
configure-index-size 13.82KB 13.82KB 0KB
dependency-chunks-size 25.76KB 25.76KB 0KB
total-bundle-size 39.58KB 39.58KB 0KB

Runtime Performance

main (0c17d81) #2922 (16b7e02) +/-
Generate Median 1,894ms 2,168ms +274ms
Generate Max 2,288ms 2,738ms +450ms
Apply Build Median 2,053ms 2,316ms +263ms
Apply Build Max 2,079ms 2,853ms +774ms

Type Performance (instantiations)

main (0c17d81) #2922 (16b7e02) +/-
tailordb-baseline 955 955 0
resolver-baseline 4,641 4,641 0
executor-baseline 848 848 0
tailordb-basic 2,385 2,385 0
tailordb-optional 1,167 1,167 0
tailordb-relation 3,808 3,808 0
tailordb-validate 186 186 0
tailordb-hooks 999 999 0
tailordb-object 1,892 1,892 0
tailordb-enum 574 574 0
resolver-basic 1,022 1,022 0
resolver-nested 3,405 3,405 0
resolver-array 1,954 1,954 0
executor-schedule 1,388 1,388 0
executor-webhook 47 47 0
executor-record-created 3,219 3,219 0
executor-record-updated 3,219 3,219 0
executor-record-deleted 3,219 3,219 0
executor-resolver 463 463 0
executor-operation-function 30 30 0
executor-operation-gql 43 43 0
executor-operation-webhook 50 50 0
executor-operation-workflow 211 211 0

Reported by octocov

@dqn
dqn marked this pull request as ready for review November 3, 2026 01:46
@dqn
dqn requested a review from a team as a code owner November 3, 2026 01:46
@dqn
dqn requested a review from toiroakr November 3, 2026 01:46

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📖 Docs Quality & Consistency Check

✅ Recommended Actions

None — docs are consistent with the implementation and contain no user-facing internal-detail leaks.

⚠️ Consistency Issues

No consistency issues found.

📝 Reader-Perspective Issues

No reader-perspective issues found.

🔍 Details

This PR changes tailor setup ci env --check to warn when TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET is set outside its GitHub Environment. The following areas were checked and found consistent:

Command Description (packages/sdk-plugin-setup/src/commands.ts:58)

  • ✅ Updated to mention "for a machine user client secret to move onto its environment"
  • ✅ Matches the new behavior of printing gh commands to move the secret

Documentation (packages/sdk/docs/github-actions.md)

  • ✅ Lines 709-716: Added warning about --check flagging repository/organization secrets, consistent with implementation
  • ✅ Lines 792: Updated "Checking what is registered" section intro to mention moving the client secret
  • ✅ Lines 799-809: New bullet explaining the ⚠ warning behavior
    • Correctly states the check still passes (no error thrown when exposedIn.length > 0)
    • Correctly describes the printed commands (gh secret set + commented-out gh secret delete)
    • Correctly notes organization secrets require owner action (no delete command generated)
    • Correctly states warning stops when secret is only on environments

Implementation Verification (packages/sdk-plugin-setup/src/env-check.ts)

  • ✅ checkRequirement (lines 45-68): Sets exposedIn for secrets in ENVIRONMENT_ONLY_SECRETS found outside environment
  • ✅ statusLine (line 330): Shows ⚠ when exposedIn.length > 0
  • ✅ report (lines 247-282): Warns with logger.warn but doesn't throw when exposedGroups exist
  • ✅ renderGhCommands in env.ts (lines 288-340): Renders set commands and commented-out delete commands

Changeset (.changeset/major-parts-remain.md)

  • ✅ Accurately describes the change from user perspective
  • ✅ Mentions exposedIn in JSON output, which matches RequirementCheck type

Reader Perspective (User-facing documentation only)

  • ✅ No internal implementation details leaked (no mention of internal functions, modules, or code structure)
  • ✅ All documentation written from SDK user's perspective
  • ✅ No JSDoc duplication or private repository references
  • ✅ Command description in commands.ts is user-facing and appropriate

Beta Marks

  • ✅ The setup command is properly marked as beta in github-actions.md (lines 11-13)
  • ✅ All commands call logBetaWarning("setup")
  • ✅ No changes to beta status in this PR

Re-run this check by adding the docs-check label to the PR.


howTo: `${MACHINE_USER_HOW_TO}; use its client secret`,
};
/** Secrets that only an environment's protection rules guard, so they belong on the environment. */
export const ENVIRONMENT_ONLY_SECRETS: ReadonlySet<string> = new Set([CLIENT_SECRET.name]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (optional): ENVIRONMENT_ONLY_SECRETS reads as "secrets that can only live on an environment", but the client secret can also sit on the repository or organization; the check only warns there.

Consider a belongsOnEnvironment: true field on CLIENT_SECRET instead, so checkRequirement no longer looks the name up in an exported one-element Set. Renaming to ENVIRONMENT_PREFERRED_SECRETS would also work.

@toiroakr toiroakr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. See the inline comment for one optional nit.

@toiroakr toiroakr assigned dqn and unassigned toiroakr Nov 3, 2026
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.

2 participants