feat: detach tokens from extension versions - #2065
Conversation
As future plans may want us to delete tokens, instead accumulate them and flag as deactivated. Summary: - Added V1_72__ExtensionVersion_PublishedBy.sql migration: new published_by_id column (FK → user_data), backfilled from published_with_id, and changed the published_with_id FK to ON DELETE SET NULL. - Added publishedBy field to ExtensionVersion (mirroring the removedBy precedent), fixed a pre-existing bug where displayName was silently excluded from equals(). - Repointed every read path (isVerified in LocalRegistryService/RelevanceService, toExtensionJson, OrphanNamespaceMigration) from getPublishedWith().getUser() to getPublishedBy(). - Redesigned PublisherComplianceChecker to iterate by publisher instead of by token, so it stays correct once tokens are deleted. - Renamed/added/deleted JPA repository methods so no query joins through personal_access_token anymore. - Rewrote ~12 raw jOOQ joins across ExtensionVersionJooqRepository and AdminStatisticCalculationsRepository to join user_data directly via published_by_id. - Applied the migration through real Flyway (via a temporary git stash of the Java changes) and regenerated jOOQ code. - Updated all affected test fixtures and mocks. - Verified: 841 unit tests + 922 integration tests (Testcontainers Postgres) all pass, and a manual SQL check confirms deleting a personal_access_token row no longer errors and correctly nulls published_with_id while leaving published_by_id intact. Note: Known follow-up (out of scope): FixTargetPlatformsJobRequestHandler still republishes using the original token and would NPE if that token were ever deleted — this is a pre-existing gap in the publish pipeline's identity model, not introduced by this change.
autumnfound
left a comment
There was a problem hiding this comment.
LGTM! Covers data migration, new field, and looks to cover all cases where the PAT was used in joins. We also have the index I'd expect for the field to keep the lookups zippy!
gnugomez
left a comment
There was a problem hiding this comment.
overall LGTM!
that's such a cleanup ◡̈
| .collect(Collectors.groupingBy(PersonalAccessToken::getUser)); | ||
| publisherTokens.keySet().forEach(user -> { | ||
| var accessTokens = publisherTokens.get(user); | ||
| if (!accessTokens.isEmpty() && !isCompliant(user)) { |
There was a problem hiding this comment.
question: I think here we're now skipping an additional check that was made before where we would first check if the non compliant user had access tokens before performing the deactivation of its extensions.
Is that something we're doing on purpose?
| @Query( | ||
| "select distinct ev.publishedBy from ExtensionVersion ev where ev.active = true and ev.publishedBy is not null" | ||
| ) | ||
| Streamable<UserData> findPublishers(); |
There was a problem hiding this comment.
now I understand where the check is!
Let's rename this to findActivePublishers or something like it, otherwise it's not completely clear that it would do that internally.
There was a problem hiding this comment.
maybe findPublishersWithActiveVersions would be more accurate, otherwise it implies that the publishers are the active subject
There was a problem hiding this comment.
Good call, renamed method to proposed one
Signed-off-by: Tamas Cservenak <tamas@cservenak.net>
Detach tokens from extension version, and allow to delete tokens, instead to preserve them as today.
Summary:
So, now: