Skip to content

wot: normalize p-tag pubkeys before they enter the graph and the cache #1340

In review

Description

@chappie-daemon

What

A contact list's p tag value is not normalized before it enters the WoT graph or the Redis cache, so an uppercase hex pubkey can sit in distances and in wot:follows:<PUBKEY> alongside the lowercase form of the same key.

Why it matters

  • pubkeySchema requires lowercase hex (src/schemas/base-schema.ts:15), so an event author is always lowercase.
  • tagSchema accepts any string (src/schemas/base-schema.ts:30), so a p value passes unchanged.
  • extractFollowedPubkeys() (src/services/wot-graph-service.ts:24) returns it as-is, and followSetKey() (:14) embeds it as-is.
  • updateFollowList() only rebuilds when this.distances.has(pubkey) (:104 on main) — an owner whose only graph entry is uppercase misses that check, so a new contact list does not trigger the rebuild that the lowercase form would.

Evidence it predates #1339

Read at main = 1b957d43, before the bounds patch: extractFollowedPubkeys, followSetKey and the distances.has(pubkey) gate all exist with the same shape. It surfaced as a CodeRabbit "Minor" on #1339, which does not touch those lines.

Suggested fix

Lowercase where the value enters the graph, not only at the cache keys — distances would still hold the uppercase form otherwise:

  • extractFollowedPubkeys: .map((tag) => tag[1].toLowerCase()).
  • The contact-list strategy: tag[1]?.toLowerCase() (optional, because a p tag with no value passes tagSchema).
  • The cache keys at src/services/wot-graph-service.ts:349 and :380.

Rejecting non-lowercase p values at input is the alternative; either way one form for every key.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions