Conversation
… CI paths - Fix _base62_decode to raise ValueError (not OverflowError) on crafted input exceeding 20-byte max; add O(1) lookup table replacing linear scan - Fix __eq__ to return NotImplemented for non-KSUID types per Python data model - Fix PrefixedKSUID prefix regex to disallow underscores (conflicts with delimiter) - Fix CI workflow to use correct `python cli.py` instead of `python -m ksuid.cli` - Correct KSUID epoch comment (May 13, 2014, not January 1, 2014) - Add security warnings to create_api_key/create_session_id docstrings - Add tests for base62 overflow and __eq__ NotImplemented behavior https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
- Add generate_token(): 160-bit pure-random base62 tokens via secrets module (no embedded timestamp), suitable for API keys and sessions - Update create_api_key()/create_session_id() to use generate_token() - Add __slots__ to KSUID class for memory efficiency - Add CLI --count upper bound (1M) to prevent memory exhaustion - Expand CI matrix to Python 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 - Upgrade actions/setup-python from v4 to v5 with allow-prereleases - Add tests for generate_token() and __slots__ behavior (30 total) https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
- Fix _base62_encode: remove early return for num==0 that bypassed zfill(27) padding, causing all-zero KSUIDs to encode as "0" instead of 27 chars (broke round-trip via from_string) - Fix test_token_has_no_predictable_timestamp: replace always-true `assert X or True` with a deterministic multi-sample check - Fix _validate_count: wrap int() in try/except to raise proper ArgumentTypeError for non-numeric --count input - Add thread-safety tests: verify uniqueness of generate() and generate_token() across 4 concurrent threads (2000 total) - Add edge-case tests: zero-value and max-timestamp round-trips 34 tests passing. https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughA new cryptographically secure token generation function is introduced alongside KSUID class hardening, including improved base62 encoding/decoding and comparison semantics. API key and session ID generation are refactored to use tokens instead of KSUID instances. CI/CD pipeline is updated to test across Python 3.9–3.14 with explicit CLI invocation and stricter input validation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
Release Notes
New Features
Improvements
Tests