Repository navigation
fix(fs): require an explicit display-name confirmation to delete a file system - #94
Conversation
There was a problem hiding this comment.
🟡 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-nameand validate delete inputs as usage errors before profile/credential loading. - Perform a pre-delete
GetAdminTenantread 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.
qiffang
left a comment
There was a problem hiding this comment.
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.
a7ecfa8 to
fe06eeb
Compare

ti fs delete-file-systemaccepted only--file-system-idand then calledDeleteAdminTenant. 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-namein 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 nameslist-file-systemsanddescribe-file-systemreport, matching the display-name semantics the flag had before it was removed.ValidateDeleteFileSystemInputsruns 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 asauthentication required. The service validates the same inputs again before remote work.GetAdminTenant, compares the trimmed confirmation with the authoritative remote display name, and only then sends the irreversible delete. A mismatch fails withfs.delete_confirmation_mismatch(exit 2), names the actual display name and thedescribe-file-systemcommand, sends no DELETE, and leaves the resource and local credentials intact.--dry-runvalidates the flags, adds adelete_confirmationcheck 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.e2e assertions removed, replacements added
e2e/cli_test.godropped the two assertions that pinned the flag's absence — help must not mention--confirm-file-system-name(wascli_test.go:94) and the flag must fail withunknown flag(wascli_test.go:213). They are replaced by:--file-system-id <string> (required)and--confirm-file-system-name <string> (required);--dry-runwith the right confirmation reportsdelete_confirmationand sends no remote request;"status": "deleting".e2e/live_test.gopasses the authoritative display name:liveFSDisplayNamedescribes the selected File System for the mutating dry-run, and the suite recordsdisplay_namefrom 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 -lclean on every changed Go file;go vet ./...clean;go build ./...clean.go test ./... -count=1passes;go test -tags ti_test_controls -run TestFakeMountReady ./internal/fs -count=1passes.make buildthenTI_E2E_BIN=$PWD/bin/ti go test ./e2e -count=1passes.TestTenantControlDeleteRequiresMatchingConfirmation(missing, blank, mismatch → one GET and no DELETE, credentials preserved; match → GET+DELETE),TestTenantControlDeleteConfirmationFallsBackToID;TestTenantControlDeleteFailurePreservesCredentialnow fails the DELETE rather than the read; the explicit-ID/credentials test also pinsfs.missing_confirmationwith zero requests.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), anddocs/present.md(definesFILE_SYSTEM_NAMEand shows the confirmed delete).Not touched:
.github/workflows/live-e2e.ymlstill references the long-removed--file-system-namein its create/cleanup steps, so that workflow was already broken before this change and needs its own fix.