Repository navigation
v3.0.0
Changed
Cuid,Cuid.generate,create_id, andcuid_wrappernow enforce the CUID2 specification length bounds (2..32, i.e.,MIN_LENGTH..BIG_LENGTH) and raiseValueErrorfor length1and lengths> 32(previously aFutureWarningin 2.3.0 andDeprecationWarningin 2.0.3–2.2.1); thecuid2CLI likewise rejects lengths outside2..32with exit code 2.Cuid,Cuid.generate,create_id, andcuid_wrappernow raiseTypeErrorfor any non-integerlength(such as afloat,Decimal,Fraction, ornumpy.bool_) when it is passed. Previously an in-range value such as10.0was accepted and failed on the first generated ID, and an out-of-range float such as0.5or100.0raisedValueError. Integer-like values such asnumpyintegers andIntEnummembers are still accepted.is_cuid(andCuid.is_cuidandcuid2 --check) now defaultsmax_lengthtoBIG_LENGTH(32, down from98, matching the upstream@paralleldrive/cuid2isCuiddefault) and clampsmax_lengthto32.
Removed
MAXIMUM_LENGTH(98) fromcuid2,cuid2.generator, andcuid2.utils; useBIG_LENGTH(32) for the maximum specification length.- Out-of-spec length
FutureWarningdeprecation machinery from the library and CLI.
Upgrade note: Callers passing length=1 or length > 32 (up to 98), or importing MAXIMUM_LENGTH must either update lengths to the CUID2 specification range (2..32) and replace MAXIMUM_LENGTH with BIG_LENGTH (32), or pin cuid2<3 until ready to migrate. is_cuid() does not raise for IDs longer than 32 characters: it returns False even when max_length is greater than 32, and cuid2 --check exits with code 1 (cuid2 --check -l N with N greater than 32 exits with code 2), so a service that validates stored legacy IDs would start rejecting them silently; validate those IDs with your own check (for example re.fullmatch(r"[a-z][0-9a-z]+", s) plus your own length bound) or pin cuid2<3. Cuid(...) and cuid_wrapper(...) validate length when constructed, so an out-of-range length in a module-level declaration (for example a Django model default in models.py) now raises ValueError at import time. Existing Django migrations that serialize functools.partial(cuid2.generator.create_id, ...) with a serialized 'length': N where N is outside 2..32 (search migration files for create_id) must be edited to a length in 2..32, otherwise operations that evaluate the default, such as AddField during migrate or test-database creation, raise ValueError.