Repository navigation
fix(web): no Follow on a profile whose id is no identity - #693
Conversation
`/u/?id=<well-formed id>` rendered an empty profile with a Follow button even when no such identity exists, so a viewer could pay to follow nobody. A typed id is now checked with one proved identity balance read (cached on a hit, never on a miss); a proved absence shows "No such identity" with no Follow, and the follow-state and first-write reads wait for the profile to load. A failed read stays the retryable error. pb-5's budget counts the new read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
Absent comes from a proof. identities.balance calls wasm-sdk getIdentityBalance. That runs IdentityBalance::fetch, which returns Ok(None) only when Drive::verify_identity_balance_for_identity_id proves the key absent, and every connection the app builds is trusted, so proofs are on. Transport errors, bad proofs and nodes past the SDK's staleness tolerance (StaleNodeError) reject, so the page shows the Retry ErrorState. A node a block or two behind can still prove a just-created id absent. That's why the miss isn't cached (lib/repo/resolveRepo.ts:121-135). Fine.
Other profiles are unaffected.
- Real ids: the read joins the existing
Promise.all, so there's no extra round trip. - DPNS names skip it (
profile-content.tsx:145). - Your own profile behaves as before, and follow is still off for it.
followRelationhas no other caller, so this was the only place a follow of a nonexistent identity could be written.
The follow-state read now waits until the profile has loaded (:177). That's correct: it no longer reads a follow relation whose target is a ?name= string.
The test fails without the fix. I ran it in a boat.dev sandbox (Node 24, pnpm 11; sandbox deleted). With the PR, 3 of 3 pass. With master's profile-content.tsx swapped in, the absent-id test fails ("expected spy to be called") and so does the failed-read test (a Follow button rendered).
Budget. The previous pb-5 bound (10+2) passed on testnet on master (run 45329408618). The PR adds exactly one read and asserts exactly one getIdentityBalance, so 11+2 (e2e/page-budget.spec.ts:72) is the old bound plus that read. The PR says plainly that the live count wasn't measured. When I posted this, this PR's playwright (read-only, testnet) job was still installing browsers, so pb-5's result on the new bound has to be confirmed when that job finishes.
Nits, not blocking:
:226'stoBe(1)fails if the SDK resends the balance read to another node.profileReadsalready has the same exposure, so this matches the existing pattern.- You could skip
identityExistswhenidentityId === identity, because the signed-in identity was proven at sign-in. That saves one read on your own profile, and a lagging node could otherwise show "No such identity" to its owner right after registration.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Problem
/u/?id=<a well-formed base58 id that is not a real identity>(e.g.7xQ3n8m2YH5bR9kLpT4vW6cZ1aFgDs8eJh2NqUyBtKiP) rendered a normal, empty profile with a Follow button.ProfileContentnever checked that a well-formed id exists, so on mainnet a viewer could spend real DASH writing a follow of a nonexistent identity.Fix
identityExists(sdk, id)(lib/repo/resolveRepo.ts) uses a provedidentities.balanceread, which is the smallest identity read.undefinedmeans Platform proved the identity absent, and a failed read rejects. A hit is cached for the session. A miss is not cached, because a node a block behind can prove a just-created identity absent, so a reload checks again. The app had no identity fetch/cache helper on the read path, so this is new, followingresolveOwner's cache shape.?id=, or?name=<id>). DPNS-resolved owners exist by construction and skip it. The read joins the page's existingPromise.all, so real profiles get no extra round trip.useRelationToggle) and the first-write reads now wait until the profile has loaded, so an absent id triggers none of them. Side effect: a?name=alicepage no longer reads the follow relation with the name as its target while DPNS resolves.ErrorState/ retry and never says "not found".Trade-off: because the existence read runs in parallel, an absent id still spends the page's other free reads (DPNS, repos, counts, profile doc) once. Running the check first would cost every real profile one serial round trip instead.
Budget
e2e/page-budget.spec.tspb-5 (a profile by?id=, cold):PROFILE_COLDgoes from 10 to 11 (+ resend slack), and the test now asserts exactly onegetIdentityBalance. The previously measured count was 9 on sakura. The +1 is the new read and has not been measured live yet. The comment says so.Testing
All of this ran in a boat.dev sandbox (Node 24, pnpm 11):
pnpm typecheck,pnpm lint,pnpm lint:copyandpnpm buildpass.components/profile-unknown-identity.test.tsxhas 3 tests:profile-content.tsxthe absent-id and failed-read tests fail. With the fix all 3 pass.pnpm test: 10165 passed. The only 3 failures are inlib/merge/xdiff.parity.test.ts, which compares against the host'sgit. The sandbox's git 2.43 lacksmerge-file --diff-algorithm, so this is unrelated to this change.🤖 Generated with Claude Code