~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The host holds what it is sent to the limits its lexicons set

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/input-checks

What changes

Text is held to its lexicon's length. A shared at_most check (bytes and characters) refuses with InvalidRequest: a role's name (64) and description (300) in putRole; an invite's message (300); a group's display name (64) and description (300) in createGroup and updateProfile; a rule's title (100) and text (2,000); a space's name (64) in createSpace and updateSpace. requestJoin now uses the same check. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjddabn7zur

putRule keys new rules by TID only. An rkey must be an existing rule's key. A new rule always gets a key from the host's clock, as rule.json's tid key says. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdewcg2qlr

createSpace refuses an empty readableBy, as updateSpace does. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdexo2eao3

createInvite takes an expiry that is still to come, at any offset. An expiresAt that is now or already past is refused. millis_of reads +HH:MM and -HH:MM offsets as well as Z, though not -00:00, as atproto's datetime does. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjddd5pgeze

Labels and notes are checked. A label's val may be at most 128 bytes. A strongRef's cid must parse. A rule must be a record's URI in a space, which a rule's URI is (space_of). atproto's strict at-uri syntax has no space URIs, so this is the check that fits. A resolve's note may be at most 300 characters. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdekblafz5

Only defined roles are given. admitMember refuses named roles the group does not define, through a new Members::defined that assignRoles now shares. putRole refuses an assignable role that is not defined, except the role being put. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjddbrubrx3

resolveSubject without action is refused with "action is required". Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdeovl22a5

Topics are cut before duplicates are dropped, so two long topics that cut to the same 64 characters are kept once. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdetbmp6h6

Profile pictures are images of the types the host serves. profile.json and updateProfile.json now accept PNG, JPEG, WebP, GIF and AVIF (IMAGES, as the console's picker offers). uploadImage refuses any other Content-Type. updateProfile takes mimeType and size from the blob the host stored, and refuses a blob that is not one of the group's images. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdeurt3ujh

PROVISIONING_CLIENTS keeps entries as written. Only HANDLE_RESOLVERS and PDS_CRAWLERS, which are service URLs, lose a trailing /. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdeqeok2cl

putRole keeps bot and assignable when they are left out, as it already did default and repoCollections. putRole.json now says so. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdd6rnfise

The lexicons only grow: wider accept lists, plus descriptions on putRule.rkey, putRole.bot/assignable and createInvite.expiresAt. The docs pages for groups, membership, moderation and configuration say what is now checked.

How it was checked

There are new cases in tests/group_config.rs (lengths, webp upload typed from the stored blob, pdf upload refused, a non-image blob refused, topics deduplicated after the cut, unknown rule key refused), members.rs (bot/assignable kept, self-assignable, undefined assignable, lengths), joining.rs (admitting with a role no longer defined), invites.rs (past expiry, offsets, message length, and millis_of cases), group_spaces.rs (empty readers, long names), moderation.rs (bad CID, long val in characters and bytes, a rule that is no record URI, long note, missing action message), groups.rs (createGroup lengths) and config.rs (trailing slashes). Each of these test binaries failed on main's source and passes here. cargo test --workspace (reference PDS tests included), clippy with warnings denied, cargo fmt, node harness/lexicons.mjs and just docs all pass locally. CI runs the coverage gate.

Shortcomings

  • Graphemes are counted as characters, as requestJoin already did. A text of combined characters (emoji sequences, combining marks) may be refused a little before its lexicon's grapheme limit, but never past it. Real grapheme segmentation would need Unicode tables this crate does not carry.
  • The lapsed-invite test now makes an invite that lapses in a second and sleeps 1.1 s, because the host no longer takes a past expiry.
  • A label's rule is checked only as a record URI in a space. It is not checked to be one of this group's rules, or to exist.

🤖 Generated with Claude Code

Approved

This pull holds the host's inputs to their lexicon limits, and I found nothing that must change. I read every source, lexicon and doc-adjacent file in the diff. I did not read the test files or the docs pages, and I did not look at the check results.

  • Length checks: at_most applies the byte and character limits in every place the body lists. requestJoin now shares it.
  • putRule: an unknown rkey is refused and a new rule is keyed by the clock.
  • createSpace: an empty readableBy is refused.
  • millis_of: it reads offsets correctly, with -00:00 refused and the offset subtracted from the time. createInvite refuses an expiry that is now or past.
  • Roles: bot and assignable now stay as they were when left out. An explicit bot: false still clears the flag. The Members::defined check, with the role being put exempt, is correct.
  • Images: updateProfile now takes mimeType and size from the stored blob, which closes the caller-supplied-metadata hole.

One small thing, not worth blocking on. words cuts a topic to 64 characters after trimming, so a cut can leave trailing whitespace on the stored topic.

Merged as 27eec5c