Skip to content

fix(fs): require an explicit display-name confirmation to delete a file system - #94

Merged
srstack merged 2 commits into
mainfrom
fix/fs-delete-confirmation
Nov 18, 2026
Merged

srstack merged 2 commits into
mainfrom
fix/fs-delete-confirmation

Conversation

@srstack

@srstack srstack commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ti fs delete-file-system accepted only --file-system-id and then called DeleteAdminTenant. Deletion is asynchronous, the backend keeps no recovery period, and there was no confirmation point: a mistyped or stale ID destroyed a file system irreversibly.

Change

The command now requires --confirm-file-system-name in addition to --file-system-id. The confirmation must repeat the target File System display name (or its ID when the backend keeps no display name) — the same names list-file-systems and describe-file-system report, matching the display-name semantics the flag had before it was removed.

  • Usage errors before auth. ValidateDeleteFileSystemInputs runs in the command handler before profile and credential loading, so a missing ID (fs.missing_file_system_id) or missing confirmation (fs.missing_confirmation) is exit 2 and sends no request, instead of surfacing as authentication required. The service validates the same inputs again before remote work.
  • Mismatch never deletes. Real execution reads the target with GetAdminTenant, compares the trimmed confirmation with the authoritative remote display name, and only then sends the irreversible delete. A mismatch fails with fs.delete_confirmation_mismatch (exit 2), names the actual display name and the describe-file-system command, sends no DELETE, and leaves the resource and local credentials intact.
  • ID fallback. A File System whose backend metadata has no display name is confirmed by its ID, because the effective name reported by list/describe already falls back to the ID.
  • Dry-run stays offline. --dry-run validates the flags, adds a delete_confirmation check and plans the DELETE, but makes no remote call. The comparison with the remote name happens on real execution, which the dry-run description states.
  • No new retry exposure. The pre-delete read is retried like any other GET; the DELETE keeps the API client's no-retry-on-mutation behavior. Local credentials are still removed only after the backend accepts deletion.

e2e assertions removed, replacements added

e2e/cli_test.go dropped the two assertions that pinned the flag's absence — help must not mention --confirm-file-system-name (was cli_test.go:94) and the flag must fail with unknown flag (was cli_test.go:213). They are replaced by:

  • help contains --file-system-id <string> (required) and --confirm-file-system-name <string> (required);
  • a missing confirmation is a usage error with no remote request;
  • a mismatched confirmation sends no DELETE and leaves the File System listed;
  • --dry-run with the right confirmation reports delete_confirmation and sends no remote request;
  • the confirmed delete returns "status": "deleting".

e2e/live_test.go passes the authoritative display name: liveFSDisplayName describes the selected File System for the mutating dry-run, and the suite records display_name from its own create response so cleanup of the resource it created can confirm it (ID fallback when empty). It never confirms a pre-existing File System, which the suite does not delete.

Verification

  • gofmt -l clean on every changed Go file; go vet ./... clean; go build ./... clean.
  • go test ./... -count=1 passes; go test -tags ti_test_controls -run TestFakeMountReady ./internal/fs -count=1 passes.
  • make build then TI_E2E_BIN=$PWD/bin/ti go test ./e2e -count=1 passes.
  • New unit tests: TestTenantControlDeleteRequiresMatchingConfirmation (missing, blank, mismatch → one GET and no DELETE, credentials preserved; match → GET+DELETE), TestTenantControlDeleteConfirmationFallsBackToID; TestTenantControlDeleteFailurePreservesCredential now fails the DELETE rather than the read; the explicit-ID/credentials test also pins fs.missing_confirmation with zero requests.
  • Manual check against the built binary: ti fs delete-file-system --file-system-id x → exit 2, --confirm-file-system-name is required for delete-file-system; deletion is irreversible, …; ti fs delete-file-system → exit 2, --file-system-id is required ….

Docs updated in README.md, AGENTS.md (rule plus command examples), and docs/present.md (defines FILE_SYSTEM_NAME and shows the confirmed delete).

Not touched: .github/workflows/live-e2e.yml still references the long-removed --file-system-name in its create/cleanup steps, so that workflow was already broken before this change and needs its own fix.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:48
@ti-chi-bot ti-chi-bot Bot added the size/XL label Nov 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A moderate active issue remains in e2e/live_test.go where liveFSDisplayName breaks the live suite when the backend returns an empty display_name, needing a fallback to File System ID to avoid failing destructive-command tests.

1 open issue
What changed in this PR

Hardens ti fs delete-file-system by requiring an explicit confirmation (--confirm-file-system-name) alongside --file-system-id, validating inputs early, and verifying the confirmation against the authoritative remote effective name (with ID fallback) before issuing an irreversible delete.

Changes:

  • Add required --confirm-file-system-name and validate delete inputs as usage errors before profile/credential loading.
  • Perform a pre-delete GetAdminTenant read to confirm the provided name matches the remote effective display name (ID fallback) prior to sending DELETE.
  • Update unit tests, e2e tests, and docs to cover missing/mismatched confirmation, dry-run behavior, and async “deleting” status.
File Description
README.md Updates CLI documentation and examples to reflect the new required confirmation flag for file system deletion.
internal/​fs/​tenant_control.go Implements delete confirmation validation and a pre-delete remote read to verify the confirmation before issuing the irreversible delete.
internal/​fs/​tenant_control_test.go Adds and adjusts unit tests for missing/blank/mismatched confirmations, ID fallback behavior, and credential preservation on failures.
internal/​fs/​drive9_companion_test.go Updates companion tests to pass the newly required delete confirmation option in relevant scenarios.
internal/​fs/​control.go Extends delete option handling and dry-run planning/reporting to include the delete confirmation check.
internal/​cli/​commands.go Wires the new required flag into the CLI, updates help/usage, and performs early validation before auth/profile loading.
e2e/​live_test.go Adjusts live e2e flows to supply the authoritative display name (or recorded value) when exercising destructive delete and dry-run behaviors.
e2e/​cli_test.go Replaces prior assertions about the flag’s absence with coverage for required confirmation, mismatch handling, dry-run behavior, and help text.
docs/​present.md Updates presentation/demo instructions to capture a file system name and demonstrate confirmed delete and dry-run usage.
AGENTS.md Documents the new delete confirmation rule and refreshes command examples accordingly.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

Comment thread e2e/live_test.go Resolved

@qiffang qiffang 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.

Reviewed exact head a7ecfa8. No substantive blockers found. Traced local ID/confirmation validation before profile/auth loading, authoritative target read and identity/display-name checks, ID fallback, read/DELETE failure handling, non-retried mutation and post-accept credential removal. Reviewed the offline dry-run contract, unit/compiled-CLI coverage, live-test cleanup selection, and documentation updates. Current CI test and CLA checks pass. Static source review; no local tests/build/live deletion executed. Advisory: add focused wrong-target-identity and pre-delete GET-failure cases when convenient.

…le system

delete-file-system accepted only --file-system-id and then called
DeleteAdminTenant. Deletion is asynchronous, the backend keeps no recovery
period, and a mistyped or stale ID therefore destroyed a file system with no
human confirmation point.

The command now requires --confirm-file-system-name in addition to
--file-system-id. The confirmation must repeat the target File System display
name (or its ID when the backend keeps no display name), matching the names
list-file-systems and describe-file-system already report.

- Missing flags are usage errors (fs.missing_file_system_id,
  fs.missing_confirmation, both exit 2) raised before profile and credential
  loading, so they never become authentication errors and never send a request.
- Real execution reads the target, compares the confirmation with the
  authoritative remote display name, and only then sends the irreversible
  delete. A mismatch fails with fs.delete_confirmation_mismatch, names the
  actual display name, and leaves the resource and local credentials intact.
- --dry-run stays offline: it validates the flags, reports a delete_confirmation
  check and the planned request, and is covered by e2e asserting no remote call.
- DELETE is still not retried by the API client; local credentials are still
  removed only after the backend accepts deletion.

e2e/cli_test.go drops the two assertions that pinned the flag's absence (help
must not mention it, CLI must report unknown flag) and now covers the required
flag in help, the missing-confirmation usage error, a mismatch that sends no
DELETE, and the offline dry-run. Live e2e passes the authoritative display name
for its dry-run and for cleanup of the resource it created itself.

Docs: README.md, AGENTS.md, and docs/present.md document the new requirement.
…tion

liveFSDisplayName failed the live suite when describe-file-system returned an
empty display_name, but delete-file-system confirms the effective name, which
the backend falls back to the File System ID. Return the ID in that case instead
of failing, so destructive-command dry-runs still cover Filesystems that keep no
display name. Decode failures still fail the test.
@srstack
srstack force-pushed the fix/fs-delete-confirmation branch from a7ecfa8 to fe06eeb Compare November 18, 2026 07:34
@srstack
srstack merged commit d4dc209 into main Nov 18, 2026
2 checks passed
@srstack
srstack deleted the fix/fs-delete-confirmation branch November 18, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants