Move API key notifications to relational tables#330
Draft
MaxEriksson2000 wants to merge 1 commit intodevelopfrom
Draft
Move API key notifications to relational tables#330MaxEriksson2000 wants to merge 1 commit intodevelopfrom
MaxEriksson2000 wants to merge 1 commit intodevelopfrom
Conversation
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
Moves API key notification user state out of JSON blobs and into relational tables, while simplifying reminder semantics from arrays to a single day threshold.
What changed
api_key_notification_preferencesandapi_key_notification_subscriptionstables with an Alembic migration that moves existing notification state out ofsettings.chatbot_widget.api_key_notificationsdays_before_expiry/default_days_before_expirycontract and route all preference/subscription reads and writes through a dedicated repositoryapi_key_policy.notification_policy, but normalize legacy array payloads to a single scalar valueexpires_atandresource_permissionscan be updated without revoke/recreatesk_keys, matching backend policy enforcementmax_days_before_expiryis lowered below the previous defaultWhy
The notification feature had started to accumulate hidden complexity in JSON blobs, plus model/UI drift around reminder arrays vs. single-value semantics. This change makes the data model explicit, easier to migrate, and easier to extend later if delivery channels are added.
Validation
bun run test:unit -- src/lib/features/api-keys/notificationPreferences.test.tsbun run checkuv run --directory backend ruff check src/intric/authentication/auth_models.py src/intric/authentication/api_key_router.py src/intric/authentication/api_key_notification_auto_follow.py src/intric/authentication/api_key_notification_repo.py src/intric/admin/admin_router.py tests/unit/test_api_key_notification_auto_follow.py tests/unit/test_api_key_notification_models.py tests/integration/test_api_key_auto_follow_publish.pyuv run --directory backend pyright src/intric/authentication/auth_models.pyuv run --directory backend alembic headsNotes
Full backend
pytestwas not runnable in this environment because the local test setup is missinglibmagic.