Avatar handle rules: 2 to 30 characters, with a Python check
A Sume avatar_handle allows a-z, 0-9, dot and underscore, 2 to 30 characters, no edge or doubled separators. A short Python check, plus the reserved prefix.
The pattern
The API accepts handles that match this pattern: 2 to 30 characters, only lowercase a to z, digits 0 to 9, dot and underscore, with no dot or underscore at the start or end, and no two separators in a row. A leading @ is dropped, as the existing guide explains.
| Handle | Passes? | Why |
|---|---|---|
| product_host | Yes | Letters and one underscore |
| a | No | Under 2 characters |
| _maya | No | Starts with a separator |
| maya_ | No | Ends with a separator |
| maya..ugc | No | Two separators in a row |
| sume_host | Passes the pattern | Fails later: reserved prefix, 409 |
Check before you pay
The same regex in Python, runnable as is:
import re
PATTERN = re.compile(r'^(?=.{2,30}$)(?![._])(?!.*[._]$)(?!.*[._]{2})[a-z0-9._]+$')
for h in ['product_host', 'a', '_maya', 'maya_', 'maya..ugc', 'x' * 31]:
print(h[:12], bool(PATTERN.match(h)))Two checks the pattern cannot make
The pattern knows nothing about the prefix or your other avatars. sume_ gives 409 avatar_handle_reserved, and a handle already in your workspace gives 409 avatar_handle_taken. Treat the regex as a first filter only.
Sources
Related posts
More in Developers
- 409 avatar_handle_taken, and how a failed avatar frees its handle
avatar_handle_taken means the handle is in use. When an avatar creation fails at reservation, the old handle is renamed so you can reuse it. Code-verified.
- Avatar photo 400 unsupported_image_type: PNG, JPEG, WebP, GIF only
Sume's avatar photo preflight accepts four image content types. An HTML page, AVIF or HEIC answer returns 400 unsupported_image_type and no job is created.
- Avatar photo 413 image_too_large: 16,384 px and 100 MP limits
A Sume avatar photo over 16,384 px on a side, or over 100,000,000 pixels, returns 413 image_too_large before any job exists. Downscale it first.
- Avatar photo image_not_fetchable: 404, timeouts and the 15 s limit
Sume gives an avatar photo host 15 seconds for fetch and body read. A non-2xx status or a timeout returns 400 image_not_fetchable. How to fix it.
Written by Sume