Skip to content

feat: Add API key validation utility to prevent runtime crashes#20

Merged
RaghavChamadiya merged 1 commit intorepowise-dev:mainfrom
sachdevlaksh:feature/api-key-validation
Apr 3, 2026
Merged

feat: Add API key validation utility to prevent runtime crashes#20
RaghavChamadiya merged 1 commit intorepowise-dev:mainfrom
sachdevlaksh:feature/api-key-validation

Conversation

@sachdevlaksh
Copy link
Copy Markdown
Contributor

@sachdevlaksh sachdevlaksh commented Apr 2, 2026

Summary

This prevents runtime errors when users attempt to use providers without proper API key setup.

  • Add validate_provider_config() function to check required environment variables
  • Enhance resolve_provider() to validate and warn about missing API keys
  • Update doctor command to include provider configuration check
  • Support validation for all providers: anthropic, openai, gemini, ollama, litellm
  • Prevent crashes by validating configuration before provider instantiation

Key Point
User steps remain unchanged.
New behavior: proactive configuration validation and warnings.
No extra CLI flags or modes required

Related Issues

Test Plan

  • Tests pass (pytest)
  • Lint passes (ruff check .)
  • Web build passes (npm run build) (if frontend changes)

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

Copy link
Copy Markdown
Collaborator

@RaghavChamadiya RaghavChamadiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work here: validate_provider_config() and the doctor integration are genuinely useful additions that go beyond what the other PRs touch. We're merging #21 for the provider constructor fix, but your helpers.py changes (passing api_key explicitly in resolve_provider) and the doctor check are worth landing separately. Could you rebase on main after #21 merges and drop the anthropic.py/openai.py changes (they'll already be in)? Happy to merge the rest.

@sachdevlaksh sachdevlaksh force-pushed the feature/api-key-validation branch from 2685e6b to b0e3839 Compare April 3, 2026 08:17
Copy link
Copy Markdown
Contributor Author

@sachdevlaksh sachdevlaksh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased onto main, dropped the provider-file changes already merged in #21, and kept only the helpers/doctor/test updates. The branch is now squashed to one commit on top of main. Could you please take another look?

Copy link
Copy Markdown
Collaborator

@RaghavChamadiya RaghavChamadiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@RaghavChamadiya RaghavChamadiya merged commit 3d30287 into repowise-dev:main Apr 3, 2026
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.

2 participants