fix(db): change secret.value from VARCHAR(255) to TEXT (fixes #5353)#6229
Open
asheesh-devops wants to merge 1 commit intokeephq:mainfrom
Open
fix(db): change secret.value from VARCHAR(255) to TEXT (fixes #5353)#6229asheesh-devops wants to merge 1 commit intokeephq:mainfrom
asheesh-devops wants to merge 1 commit intokeephq:mainfrom
Conversation
…eephq#5353) OAuth tokens exceed 255 chars causing silent truncation on MySQL and JSON parse errors during provider installation. Changed the column type to TEXT and added an Alembic migration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes silent truncation of OAuth tokens in the
secrettable when usingSECRET_MANAGER_TYPE=dbwith MySQL, which caused JSON parse errors and HTTP 400/500 during provider installation.Root Cause
The
Secretmodel definesvalue: strwithout an explicit column type, which SQLModel/SQLAlchemy maps toVARCHAR(255)on MySQL. OAuth tokens from providers like PagerDuty and Flux routinely exceed 255 characters, causing silent truncation:The truncated JSON then fails to parse:
The Fix
Change the column type to
TEXTwhich has no practical size limit:Added an Alembic migration using
batch_alter_table(SQLite-safe) to alter the column for existing deployments.Changes
keep/api/models/db/secret.py— changevaluefield to useTEXTcolumn typekeep/api/models/db/migrations/versions/2025-06-19-10-00_a1b2c3d4e5f6.py— Alembic migration to alter existingVARCHAR(255)toTEXTTesting
sa_column=Column(TEXT)pattern is used throughout Keep's models (e.g.,workflow_raw,name,descriptioninworkflow.py)batch_alter_tablefor SQLite compatibilityVARCHAR→TEXTis a safe, non-destructive migrationFixes #5353