Repository navigation
Description
Why?
The pre-release review for 0.5.0 found that in moderated mode any logged-in user can add pending service types without limit, through POST /services/types or failed POST /services requests (the pending type is stored before the registration is validated). Every non-admin read (GET /services, GET /services/{id}, the verification reads, and admin GET /approvals) then builds a filter with one clause per pending type, used or not. Reads slow down as the count grows and fail with 500 above about 20,000 long types, because the query exceeds MongoDB's 16 MiB limit (reproduced on MongoDB 7.0 with 25,000 types). service_types.pending has no index.
In open mode (the default), the public, unpaginated GET /services/types grows the same way, and only admins can remove types, one at a time.
What?
- Build the visibility filter only from pending types that stored services use, e.g. a derived, indexed
pendingflag on services that registration sets and approval clears with an idempotentupdate_many(no transactions needed), or adistinctover the services' types. - Index
service_types.pending. - A configurable cap on the unused types a non-admin may have added (pending in
moderated, approved inopen); above it, 409 with a clear detail. - Don't store a pending type when the registration that would create it fails validation, where that's possible without transactions; otherwise document it.
- Fix
docs/configuration.md: 0.4.0 stores no types; existing types are approved by the startup backfill. - Document the remaining abuse vector next to the modes and recommend rate limits for
POST /services/types.
Acceptance criteria
- Read cost no longer grows with unused pending types; a test with many pending types stays well under the BSON limit.
- The cap is enforced and tested in both modes; admins are exempt.
Activity
docs: add bounded service types to 0.5.0