The allowlist. Lowercase letters, digits, and ./-/_ after the first
character.
Two decisions worth stating, because both look like something to "fix":
Uppercase is rejected rather than folded to lowercase. The obvious
kindness — accept Alice, store under alice — is a trap here, because the
username also lives inside the document, which is hand-editable and
round-trips verbatim. Folding on the way in would make the stream key
disagree with the document's own username field, which is precisely the
mismatch PUT refuses. Rejecting with a message that says "lowercase"
leaves one spelling of a name, one stream, and nothing silently rewritten.
It would also make Alice and alice look like one account in some places
and two in others.
The first character must be a letter or a digit, so a name cannot be
., .., -rf, or anything else that reads as punctuation rather than as
a person when it turns up in a log line or a filename someone derives from
it.
Built from USERNAME_MAX_LENGTH rather than restating the bound, so the cap and
the pattern cannot drift apart.
The allowlist. Lowercase letters, digits, and
./-/_after the first character.Two decisions worth stating, because both look like something to "fix":
Alice, store underalice— is a trap here, because the username also lives inside the document, which is hand-editable and round-trips verbatim. Folding on the way in would make the stream key disagree with the document's ownusernamefield, which is precisely the mismatchPUTrefuses. Rejecting with a message that says "lowercase" leaves one spelling of a name, one stream, and nothing silently rewritten. It would also makeAliceandalicelook like one account in some places and two in others..,..,-rf, or anything else that reads as punctuation rather than as a person when it turns up in a log line or a filename someone derives from it.Built from
USERNAME_MAX_LENGTHrather than restating the bound, so the cap and the pattern cannot drift apart.