fix(gl): report quickstart registration failure when the node returns no UCAN (#355) - #458
beardthelion wants to merge 1 commit into
Conversation
… no UCAN (Twigpine#355) A 2xx with a non-JSON or ucan-less body still printed "Registered successfully / UCAN saved to ..." while nothing was written, and left a stale ucan.json from another node in place. Print the success lines only when a UCAN was actually persisted.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthrough
ChangesQuickstart registration
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Quickstart now reports registration failure for unusable responses while preserving the existing continuation behavior, with no identified merge-blocking impact. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue Resolution When a 2xx registration response has no usable UCAN, remove or invalidate an existing
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR corrects
Confidence Score: 5/5The PR appears safe to merge and correctly prevents a no-UCAN response from being reported as successful registration. The new branch accurately reflects whether a usable UCAN was saved and preserves the command’s established behavior of continuing after registration failures; no actionable regression was identified.
|
| Filename | Overview |
|---|---|
| crates/gl/src/quickstart.rs | Aligns registration status output with the existing UCAN persistence guard while preserving quickstart’s intentionally non-fatal control flow. |
Reviews (1): Last reviewed commit: "fix(gl): report quickstart registration ..." | Re-trigger Greptile
jatmn
left a comment
There was a problem hiding this comment.
I found one issue to address before this is ready.
Merge readiness
GitHub reports this head as mergeable, but review is required and cargo audit failed. The diff has no dependency or lockfile change, and the same audit job failed on PR #459 from the same main base, so the failure appears unrelated to this patch; its exact advisory log was unavailable through GitHub CLI. Resolve or explicitly triage that check before merge. Current main is still bfc44f9, the captured merge base, so this branch does not currently need a rebase. PR #459 changes the same quickstart registration hunk to secure secret-file writes; if it merges first, resolve the overlap and recheck the combined behavior.
Findings
🔵 P3 — Do not direct the retry to a different identity
📍 Where: crates/gl/src/quickstart.rs:120, the new no-UCAN failure branch.
💥 What fails: Run gl quickstart --dir /custom/identity --node N against a node that returns 2xx without a UCAN. The new instruction says gl register --node N. Following it makes gl register read ~/.gitlawb/identity.pem instead of /custom/identity/identity.pem. The retry fails before contacting the node when the default identity is absent; if one exists, it can register a different DID and save its UCAN in the wrong directory. A local binary stub reproduced the new instruction with a custom --dir and no UCAN write.
🔎 Root cause: The new recovery instruction carries the selected node but drops the identity directory that quickstart used to create and send the registration request. register::run has its own --dir option and otherwise loads the default identity.
📜 Stated contract:
The new operator output says “You can retry with: gl register --node …”; both commands document
--diras “Identity directory (default: ~/.gitlawb).”
🏷️ Attribution: PR-introduced on this response path. At merge base and live main (bfc44f9), a 2xx without UCAN printed false success and no retry command. At head (a418c28), the newly added retry command omits --dir. The older non-2xx and transport hints have the same omission, but their output is unchanged by this PR.
📌 In this PR:
- The no-UCAN branch at line 120 — omits the selected identity directory. There are no other changed retry hints, docs, or generated operator surfaces in this diff.
🔒 Unchanged on main: The old quickstart error hints, gl register identity loading, and the other-node UCAN record behavior are outside this finding.
🔧 Required correction: Remove this new retry instruction, or make it preserve quickstart's selected --dir if the hint remains. If printed, the directory must be one shell argument, including paths with spaces. Add focused regression evidence that a no-UCAN response with a custom directory reports failure without directing the user to a different identity. Keep the existing nonfatal continuation to repo creation.
🛠️ Author fix: Close the false recovery instruction on the one in-diff branch and cover that behavior. The accepted issue requires a failure warning; it does not require a retry command. Do not rebuild gl register, the shared UCAN decoder, or unrelated quickstart failure paths for this patch.
🚫 Out of scope: Rewriting the pre-existing gl register no-UCAN behavior, clearing a valid UCAN for another node, or making registration failure fatal.
Validation
cargo fmt --all -- --check passed. cargo test -p gl --locked passed 363 tests; none exercises quickstart's new output branch. A local stub returned non-JSON 200 for registration: quickstart printed registration failure, printed the incorrect retry instruction with a custom --dir, wrote no UCAN, and exited 0 through its established nonfatal flow. Four blind full-diff searches and a separate coverage-gap search were reconciled against the current head, merge base, and live target.
euxaristia
left a comment
There was a problem hiding this comment.
Faithful to #355: the success prints moved inside the non-empty guard with a failure row and retry hint. No automated test, but the changed seam is print-only and verified by binary run; acceptable.
Summary
gl quickstartprinted "Registered successfully" and "UCAN saved to ..." on any 2xx from/api/register, including a non-JSON body whereresp.json()falls back toValue::Null. Nothing was written, and a staleucan.jsonfrom another node stayed in place while the output claimed success.Motivation & context
Closes #355
Kind of change
What changed
crates/gl/src/quickstart.rs: the success lines moved inside the!ucan.is_empty()guard that already covered the write. A 2xx with no usableucannow prints a failure row with a retry hint instead.How a reviewer can verify
Ran the built binary against a stub node returning
200 text/htmlon/api/register:Registered successfully/UCAN saved to <path>with noucan.jsonwrittenRegistration returned no UCAN (unexpected response body), still noucan.json, exit continues to step 3 as beforecargo test -p glBefore you request review
cargo test -p glpasses locallycargo fmt --allandcargo clippy -p gl --all-targets -- -D warningsare cleanfeat(...),fix(...),docs(...)).env.exampleupdated if behavior or config changed (or N/A)Protocol & signing impact
did:key, Ed25519 / RFC 9421 signatures, UCAN, ref certs, or P2P wire formatsNotes for reviewers
Overlaps the #354 fix PR in
quickstart.rs's register arm: whichever merges second needs a small rebase.Summary by CodeRabbit
gl quickstarthandling when registration succeeds without a usable UCAN.