feat(datasets): warn before public visibility and gate --yes for agents#998
feat(datasets): warn before public visibility and gate --yes for agents#998EoinFalconer wants to merge 3 commits intomainfrom
Conversation
Add clearer warnings when a dataset is created as or changed to public, and require --yes for non-interactive private→public transitions so agents/CI cannot silently expose data. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @EoinFalconer's task in 2m 13s —— View job Code Review
Issues1. Missing tests for There is no test file for The two untested paths are:
A test file at 2. Unreachable The // set.ts lines 118–126
} catch (error) {
if (error instanceof NonInteractiveError) {
this.error('Refusing to change dataset to public ...', {exit: 1})
}
throw error // ← unreachable in practice
}
3. Changeset The
This is accurate but undersells the breaking impact for existing non-interactive callers. Consider: "Non-interactive callers (CI, agents) must now pass Open question (from PR description)
Agreed that a warning is sufficient for |
|
⏳ Bundle Stats — Calculating bundle sizes for @sanity/cli, @sanity/cli-core, create-sanity... |
Coverage Delta
Comparing 3 changed files against main @ Overall Coverage
|
- Use char: 'y' so -y short flag is actually recognised (aliases only creates long-form --y). - Switch --yes acknowledgement from this.warn to this.log; it's a confirmation, not a warning, and warn formatting looks alarming in CI logs. - Add manual changeset describing the user-facing effect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Description
Makes the safety implications of public datasets clearly visible in the CLI, and prevents non-interactive callers (agents, CI) from silently flipping a dataset from private to public.
Specifically:
datasets createinteractive prompt (promptForDatasetAclMode): when the user picks "Public", emit an explicit warning that anyone on the internet can read the data and suggest "Private" for sensitive content.datasets create --visibility public(determineDatasetAclMode): emit the same style of warning so agents that pass the flag are warned too.datasets visibility set <ds> public:No).--yes/-yis provided — so agents/CI cannot accidentally leak data.--yesflag documented in help and examples.The
public → privatepath is intentionally unchanged — only the direction that exposes data is gated.What to review
packages/@sanity/cli/src/prompts/promptForDatasetAclMode.ts— new public-side warning; existing private-side note preserved.packages/@sanity/cli/src/actions/dataset/determineDatasetAclMode.ts— warning for explicit--visibility public.packages/@sanity/cli/src/commands/datasets/visibility/set.ts— new--yesflag, warning + confirmation,NonInteractiveErrorhandling.packages/@sanity/cli/src/commands/datasets/visibility/__tests__/set.test.ts— new coverage for the four flows (confirm accept, confirm decline,--yesbypass, non-interactive without--yeserror).Please eyeball the warning copy — happy to tighten it if it's too verbose or too mild. Open question: should
datasets createalso gate with--yesfor agents, or is a warning enough since no data exists yet?Testing
set.test.ts. Fullpnpm test --changedgreen (134/134).datasets create --visibility public→ warning printed ✅datasets visibility set <ds> public(no TTY, no--yes) → exit 1, no API call ✅datasets visibility set <ds> public --yes→ warning + acknowledgement + flip ✅datasets visibility set <ds> private→ unchanged ✅