THU-505: Move model API keys to local-only table#858
THU-505: Move model API keys to local-only table#858raivieiraadriano92 wants to merge 11 commits into
Conversation
Semgrep Security ScanNo security issues found. |
|
Preview environment deployed 🚀
Stack: Auto-destroys on PR close/merge. Login via the bundled Keycloak realm — |
PR Metrics
Updated Fri, 15 May 2026 10:36:49 GMT · run #1504 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5750349. Configure here.
| model.provider, | ||
| model.model, | ||
| model.url, | ||
| model.apiKey, |
There was a problem hiding this comment.
Hash algorithm change breaks modification detection for existing models
Medium Severity
Removing apiKey from the hashValues array in hashModel shifts every subsequent field one position left, producing a completely different hash — even when apiKey was always null for system models. Any model with a previously stored defaultHash (computed with the old algorithm) will now fail the equality check in isModelModified, causing all such models to incorrectly display as "customized" with a reset indicator.
Reviewed by Cursor Bugbot for commit 5750349. Configure here.


Summary
api_keyout of the syncedmodelstable into a new local-onlymodels_secretstable that PowerSync never syncs — API keys never leave the devicemodels_secretsso consumers still getapiKeytransparentlyapi_keyfrom E2EE encrypted columns and backend schema (with migration)Test plan
models_secrets, not inmodelsmodels_secretsupdated, warning disappearsmodels_secretsrow deletedapiKey: null, no warning shown🤖 Generated with Claude Code
Note
Medium Risk
Schema and DAL changes move
apiKeystorage and retrieval, which can break model configuration and provider authentication if joins/migrations are wrong, but scope is limited to models/settings UI and persistence.Overview
Moves model API keys out of sync scope. Drops
api_keyfrom the backendpowersync.modelstable (new migration + updated Drizzle schema) and removes it from the E2EE encrypted-columns list.Introduces a local-only
models_secretstable in the client SQLite schema and PowerSync app schema (markedlocalOnly) to storeapiKeyon-device only, with new relations.Updates the models DAL to transparently include
apiKey. All model reads nowLEFT JOINmodels_secrets, andcreateModel/updateModel/resetModelToDefault/deleteModelmanage secrets in transactions (including manual upsert behavior).UI/UX updates for missing keys and editing. The model selector and models settings list now flag and disable models that need an API key but don’t have one (amber warning + tooltip), and the settings page replaces the removed detail/new routes with an inline edit modal plus a consolidated delete confirmation.
Tests adjusted/added to cover
models_secretspersistence, join behavior, update semantics, and cascade delete.Reviewed by Cursor Bugbot for commit 5750349. Bugbot is set up for automated code reviews on this repo. Configure here.