Skip to content

fix(web): no Follow on a profile whose id is no identity - #693

Merged
PastaPastaPasta merged 1 commit into
masterfrom
fix/profile-unknown-identity
Nov 24, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
fix/profile-unknown-identity

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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. ProfileContent never 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 proved identities.balance read, which is the smallest identity read. undefined means 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, following resolveOwner's cache shape.
  • The profile runs this read only when the address itself is an identity id (?id=, or ?name=<id>). DPNS-resolved owners exist by construction and skip it. The read joins the page's existing Promise.all, so real profiles get no extra round trip.
  • When the identity is proved absent, the page shows a "No such identity" empty state ("No identity … exists on .") with no profile card and no Follow. The follow-state read (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=alice page no longer reads the follow relation with the name as its target while DPNS resolves.
  • A network error rejects the read, so the page shows the existing 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.ts pb-5 (a profile by ?id=, cold): PROFILE_COLD goes from 10 to 11 (+ resend slack), and the test now asserts exactly one getIdentityBalance. 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:copy and pnpm build pass.
  • New components/profile-unknown-identity.test.tsx has 3 tests:
    • absent id: "No such identity", no Follow, follow read never enabled
    • real id: profile card and Follow
    • failed read: retryable error, never "not found"
  • Against master's profile-content.tsx the absent-id and failed-read tests fail. With the fix all 3 pass.
  • Full pnpm test: 10165 passed. The only 3 failures are in lib/merge/xdiff.parity.test.ts, which compares against the host's git. The sandbox's git 2.43 lacks merge-file --diff-algorithm, so this is unrelated to this change.
  • Not run: the live Playwright pb-5 against a network.

🤖 Generated with Claude Code

`/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]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d565598-77f5-4e73-9f11-5f2ff0dc8a48
Commits

Reviewing files that changed from the base of the PR and between d582ba2 and 48aa726.

Files selected for processing: 5

  • forge-web/components/profile-content.tsx
  • forge-web/components/profile-unknown-identity.test.tsx
  • forge-web/e2e/page-budget.spec.ts
  • forge-web/lib/repo/index.ts
  • forge-web/lib/repo/resolveRepo.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.
  • followRelation has 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's toBe(1) fails if the SDK resends the balance read to another node. profileReads already has the same exposure, so this matches the existing pattern.
  • You could skip identityExists when identityId === 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.

@PastaPastaPasta
PastaPastaPasta merged commit 16ace84 into master Nov 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant