Skip to content

fix: widen api_keys.key_prefix from 12 to 20 chars - #83

Merged
man4ish merged 2 commits into
mainfrom
fix/api-key-prefix-column-width
Oct 4, 2026
Merged

man4ish merged 2 commits into
mainfrom
fix/api-key-prefix-column-width

Conversation

@man4ish

@man4ish man4ish commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

M13 (live/test key prefixes) changed the stored prefix to len("omni_sk_live_"/"omni_sk_test_") + 4 display chars = 17 characters, but never widened this column from its pre-M13 size of 12 (sized for the plain omni_sk_XXXX scheme).

Impact: every real key creation against a real MySQL database has failed with Data too long for column 'key_prefix' since M13 shipped. SQLite enforces no VARCHAR length limit at all, so the existing (SQLite-backed) test suite never caught this -- found while testing a real account's "Create key" flow against a live MySQL-backed stack.

Test plan

  • pytest tests/test_apikeys.py tests/test_me_api_keys.py tests/test_apikey_exchange.py -q -- 50 passed
  • alembic heads -- single head, chain intact
  • Reproduced the real MySQL DataError directly against the live stack before fixing, confirmed ALTER TABLE api_keys MODIFY COLUMN key_prefix VARCHAR(20) + model change resolves it (full round trip: license login -> create key -> succeeds)

🤖 Generated with Claude Code

man4ish and others added 2 commits October 4, 2026 10:37
M13 (live/test key prefixes) changed the stored prefix to
len("omni_sk_live_"/"omni_sk_test_") + 4 display chars = 17 characters,
but never widened this column from its pre-M13 size of 12 (sized for
the plain "omni_sk_XXXX" scheme).

Impact: every real key creation against a real MySQL database has
failed with "Data too long for column 'key_prefix'" since M13 shipped.
SQLite enforces no VARCHAR length limit at all, so the existing
(SQLite-backed) test suite never caught this -- found while testing a
real account's "Create key" flow against a live MySQL-backed stack.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Two tests pinned the full-upgrade alembic_version to the previous
head (0028_auth_audit_integrity); update both to the new head this
branch adds (0029_widen_api_key_prefix).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@man4ish
man4ish merged commit 7fd6ab2 into main Oct 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant