-
Notifications
You must be signed in to change notification settings - Fork 203
mito-ai: remove api key traitlet #2150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| return AICapabilities( | ||
| configuration={"model": "<dynamic>"}, | ||
| provider="OpenAI", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid API key reports wrong provider capabilities
Medium Severity
The capabilities and key_type properties now check raw constants.OPENAI_API_KEY (an unvalidated environment variable) instead of delegating to self._openai_client.capabilities which checks the validated self.api_key. When a user sets an invalid OpenAI API key, OpenAIClient validates it and sets self.api_key = None, but constants.OPENAI_API_KEY remains truthy. The new code reports provider="OpenAI" and key_type="openai" even for invalid keys, while actual API calls fall back to Mito server. This causes incorrect provider information to be shown to users.
Additional Locations (1)
| ) | ||
|
|
||
| if constants.OLLAMA_MODEL and not self.api_key: | ||
| if constants.OLLAMA_MODEL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orphaned traitlet decorators reference removed api_key attribute
High Severity
The api_key Unicode traitlet was removed from OpenAIClient, but the @default("api_key") decorator (line 63) and @validate("api_key") decorator (line 68) with their associated methods were left behind. These decorators reference a non-existent trait, which will cause a TraitError when the class is instantiated because traitlets cannot find the api_key attribute to bind these handlers to. The _validate_api_key method also makes HTTP calls to OpenAI to validate keys, which is now unreachable dead code.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context, and the specification if there is one.
Testing
Please provide a list of the ways you can "access" or use the functionality. Please try and be exhaustive here, and make sure that you test everything you list.
Documentation
Note if any new documentation needs to addressed or reviewed.
Note
Modernizes provider configuration and capabilities handling.
CLAUDE_API_KEYwithANTHROPIC_API_KEYacrossconstants, provider routing, and testsapi_keyconfig plumbing fromOpenAIClient/ProviderManager; rely onOPENAI_API_KEY/env for selectionprovider: "OpenAI"withmodel: "<dynamic>"); simplifykey_typetouser_keywhen any user provider env/model is presentWritten by Cursor Bugbot for commit 68a3626. This will update automatically on new commits. Configure here.