fix(token): honor expires_type 'never' in user token validation & fix test module collision - #3266
Merged
lbjlaq merged 2 commits intoJul 27, 2026
Conversation
…icate test module name
There was a problem hiding this comment.
Pull request overview
This PR fixes token validation so non-expiring user tokens (expires_type: "never") are not incorrectly rejected as expired, and resolves a Rust test module name collision that prevented tests from compiling.
Changes:
- Update
validate_token()to skip expiration timestamp checks whenexpires_type == "never". - Add a unit test ensuring
"never"tokens validate successfully. - Rename a duplicate test module in the Claude proxy handler to avoid
E0428duplicate-definition errors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src-tauri/src/modules/user_token_db.rs |
Adjusts token expiration validation logic and adds a unit test for "never" tokens. |
src-tauri/src/proxy/handlers/claude.rs |
Renames a test module to eliminate a duplicate module name collision during compilation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| )); | ||
| if token.expires_type != "never" { | ||
| if let Some(expires_at) = token.expires_at { | ||
| if expires_at > 0 && expires_at < Utc::now().timestamp() { |
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.
Description
1. Fix User Token Expiration Validation
When a user token was created or updated with
expires_type: "never", itsexpires_atcolumn in SQLite could be0orNULL. Previously,validate_token()insrc-tauri/src/modules/user_token_db.rscheckedif expires_at < Utc::now().timestamp(). Because0 < nowevaluated totrue, non-expiring tokens were incorrectly flagged as expired (403 Forbidden).This PR updates
validate_token()to checkif token.expires_type != "never"andexpires_at > 0before evaluating timestamp expiration, ensuring tokens set toneverremain valid indefinitely. Unit tests for this behavior have also been added.2. Fix Duplicate Test Module Collision
Renamed duplicate
mod variant_testsinsrc-tauri/src/proxy/handlers/claude.rstomod opus_variant_teststo resolve compiler errorE0428during test execution.Testing
test_never_expire_token_validationandopus_variant_tests. All passed cleanly./v1/chat/completionswith modelclaude-opus-4-6-thinkingreturning200 OKusing a non-expiring token.