fix: relax Trakt Client ID validation to accept new format - #21
Open
avolk201 wants to merge 7 commits into
Open
Conversation
Trakt has changed their API key format. New Client IDs are no longer restricted to 64-character lowercase hex strings — they can be shorter (e.g. 43 characters) and contain uppercase letters, underscores, and hyphens. Updated the validation regex in both the shared Zod schema (used by the frontend form and tRPC router) and the server-side Value Object (used when loading from persistence) to accept alphanumeric strings with underscores/hyphens, requiring a minimum of 20 characters. Fixes guillevc#19
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.
Problem
Trakt has changed their API key format. New Client IDs generated from the updated application creation page are no longer 64-character lowercase hex strings — they can be shorter (e.g. 43 characters) and contain uppercase letters, underscores, and hyphens.
The current validation regex (
/^[0-9a-f]{64}$/) rejects these new-format Client IDs, making it impossible for users to connect their Trakt accounts.Solution
Relaxed the validation regex in both the shared Zod schema (used by the frontend form and tRPC router) and the server-side Value Object (used when loading from persistence) to accept alphanumeric strings with underscores and hyphens, requiring a minimum of 20 characters.
New regex:
/^[0-9a-zA-Z_-]{20,}$/This accepts both:
a1b2c3d4....)Files Changed
packages/shared/src/presentation/schemas/trakt.schema.ts— Relaxed Zod schema regexpackages/server/src/domain/value-objects/trakt-client-id.vo.ts— Relaxed server-side persistence validationFixes #19