Repository navigation
fix(cli): say the right thing for webhooks, setup codes, unreachable servers and keychains - #2258
Conversation
aicayzer
left a comment
There was a problem hiding this comment.
Review: ready to merge
Summary. The CLI's words and exit codes now say what happened: delivery status in webhooks deliveries, the reason a redelivery is refused, the webhook secret printed once, exit 1 for a wrong setup code, the server's origin in a network error, and an unreadable keychain named as such; safe to merge.
First draft: 3/5. 1 blocking issue and 3 smaller ones found; the blocking one and one smaller one fixed in a655b007b and 9272e09f6, prose in 8f9ff33dc.
Found.
- Blocking: naming an unreadable keychain made
folders pull,folders restoreanddevice blobs getstop instead of running offline, which is the normal state over SSH on a Mac. Fixed: those three treat an unreadable keychain as nothing kept; every other command still exits 4. The statement and a conformance test follow it. - The console's retry notice guessed at the reason the server now states. Fixed: it shows the server's message.
delivery_not_retainedis reachable only through a damaged row. Kept as a last fallback.- A stream that breaks after it opens does not name the server. Left: the path, query and key never appear, and the origin is named where the connection is made.
Checked. setup_proof_invalid is thrown wherever a setup proof was refused, and matched by the setup pages; redelivery reasons are checked only after the caller can see the webhook, so nothing crosses owners; #2249's access rules are unchanged; network errors carry the origin only.
Linux has no keychain file, so nothing can be kept there; keeping or removing an entry is still refused with the reason.
Off macOS a named keychain file reads as holding nothing, so no server named is the true answer there. The Node watch test now checks the unreachable reason names the server.
Summary
Six small points in the command line's words and exit codes that a person meets on a first day: a webhook's deliveries said nothing useful, a refused redelivery gave no reason, a new webhook's secret was buried in a description, a wrong setup code exited like a bad key, an unreachable server did not say which one, and a locked keychain was reported as "no server named".
Changes
webhooks deliveriesshows each delivery's status, event, attempts and the receiver's answer (core/marfa-cli/src/output.rs).409 conflictanddetails.reasonset to one ofwebhook_inactive,credential_unavailable,delivery_not_failed,delivery_expiredordelivery_not_retained, in words (packages/server/src/routes/webhooks.ts; contractevents/redeliver-conflict-reason).webhooks createprints the signing secret alone on the first line, askeys createdoes, then a description that never repeats it. A--secretthe person gave is not echoed.--jsonstill returnssecret.setup_proof_invalid(status 401), and the CLI exits 1 for it instead of 5 (packages/shared/src/errors.ts,auth/instance-claim.ts,routes/setup.ts,core/marfa-cli/src/error.rs; contractdevice/claim-refused-proof-exit, theinstance-claimstatements, the errors table).request to <origin> failed: <cause>, and thenetworkerror no longer starts its message with its own code (core/marfa-core/src/http.rs,error.rs; contractdevice/command-unreachable-origin,device/command-unreachable-code-once).no_keychain(exit 4) with the keychain's own reason, not asno_server(core/marfa-cli/src/remote/mod.rs; contractdevice/command-keychain-unreadable). With the keychain off or empty,no_server(exit 2) stays.folders pull,folders restoreanddevice blobs getstill run on held bytes alone when the keychain cannot be read, as over SSH on a Mac with no default keychain (Named::session_if_named).error.message, and falls back to the general sentence only when there is none (packages/server/src/pages/client/webhooks.ts).openapi.json, the generated client schema, the errors table andCOMMANDS.mdare regenerated.Testing
webhook-redelivery-refusals.test.ts, with a witness that a failed delivery is accepted), the setup code exit (Rust unit test anddevice/contract.test.tswith the CLI change removed, exit 5), the error code (instance-claim.test.ts, four tests failing with the source reverted), the unreachable origin (Rust test) and the keychain (device/contract.test.ts, exit 2 before, 4 after, with a witness for the keychain-off case that still exits 2).cargo fmt --check,cargo clippy --all-targets -- -D warnings(marfa-cli, marfa-core, the Swift binding),cargo test -p marfa-cli --bin marfa(300),cargo nextest run -p marfa-core(859) and the Swift binding (50),pnpm format:check,pnpm lint,pnpm typecheck, andpnpm test:changed(all passed, including the spec-form, OpenAPI style and settings census checks).delivery_not_failedandwebhook_inactivereasons, thewebhooks createoutput and--json, a wrong setup code against a real unclaimed server (exit 1,server.codesetup_proof_invalid), an unreachable address and a DNS failure, and a locked, missing and unreadable scratch keychain (old binary: "no server named", exit 2; new: "the keychain cannot be used: ", exit 4). No login keychain was used.device/contract.test.tstest runsfolders pullandwhoamiwithMARFA_KEYCHAINnaming a missing file; it failed first (pull exit 4), then passed (pull exit 0,whoamiexit 4, andfolders pull --urlexit 5no_credential). The retry notice change has no browser test and was not run in a browser.cargo fmt --checkhad failed ondrain.rsfrom an earlier commit on this branch, so that is formatted.webhooks createlayout has unit tests written with the change, not seen failing first; the redelivery reasonsdelivery_expired,delivery_not_retainedandcredential_unavailableare covered by server tests but not run through the CLI;cli/exits.test.tsand the webhook conformance files were not run against a booted server; the keychain change is untested on Linux; the literal doublednetwork: network:was not reproduced (the repeat came from surfaces printing the code beside a message that began with it); the host on which the keychain symptom was reported (Atlas) was not reproduced on, only a locked or unreadable keychain on this Mac; the Swift package inmarfa-swiftwas not checked for the oldnetwork:text.Notes for reviewers
decoding:andstore:error prefixes repeat their code the same way;auth::resolve_credentialandlogin.rsstill treat an unreadable keychain as "no credential"; the drain and blob wrappers keep "the server could not be reached" because conformance tests match that text.folders pull,folders restore, device blob read) runs on held bytes when the keychain cannot be read; every other command reportsno_keychainwith exit 4.error.codeunauthorized(the CLI derives it from the status) and carries the server's code inerror.server.code; the exit is 1.Exit::meaningfor refused and local), the webhook CLI output (deliveries listing, the creation output), and the secret handling (secret first line, never repeated,--secretnot echoed).core/marfa-core/src/drain.rsand fix(server): make the owner-facing words true and consistent #2257 and fix(cli): keep item content off the private socket and say so #2256 toucherror.rs,remote/mod.rs,device.mdandCOMMANDS.md; this branch is rebased on currentmainand the edits are in different places, but whichever merges second regeneratesCOMMANDS.md.Checklist