Skip to content

fix: validate cached tokens during client initialization#33

Open
prabhakarpujeri wants to merge 1 commit intohuggingface:mainfrom
prabhakarpujeri:fix/validate-cached-tokens
Open

fix: validate cached tokens during client initialization#33
prabhakarpujeri wants to merge 1 commit intohuggingface:mainfrom
prabhakarpujeri:fix/validate-cached-tokens

Conversation

@prabhakarpujeri
Copy link
Copy Markdown

Summary

  • Fix token validation bypass where cached tokens were not validated
  • Add unit tests for cached token validation scenarios

Problem

Previously, only explicitly provided tokens were validated during DellAIClient initialization. Tokens loaded from the Hugging Face cache were used without validation, causing silent failures when users had expired or invalid cached tokens.

Solution

Changed the validation logic in client.py:48-55 to validate all tokens regardless of source (explicit or cached).

Changes

  • dell_ai/client.py - Validate all tokens, not just explicit ones
  • tests/unit/test_client.py - Added 2 new tests:
    • test_initialization_with_invalid_cached_token
    • test_initialization_with_valid_cached_token

Test plan

  • All 82 existing tests pass
  • New tests verify cached token validation
  • Invalid cached tokens now raise AuthenticationError

Fixes #29

Previously, only explicitly provided tokens were validated during
DellAIClient initialization. Tokens loaded from the Hugging Face
cache were used without validation, which could cause silent failures
when users had expired or invalid cached tokens.

This change ensures all tokens are validated regardless of source,
providing immediate feedback when authentication credentials are invalid.

Fixes huggingface#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Token validation bypass - cached tokens are not validated

1 participant