Fix #72: Set default OPENAI_API_KEY to prevent startup crashes #74
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.
Summary
Fixes #72 by implementing a graceful solution for missing
OPENAI_API_KEYenvironment variable that prevents application startup crashes.Changes Made
Core Implementation
struct_module/model_wrapper.py:sk-default-placeholder-key) whenOPENAI_API_KEYis not set for OpenAI modelsgenerate_content()method to detect placeholder keys and provide user-friendly messagesTesting
tests/test_model_wrapper.py:Benefits
✅ Prevents crashes: Tool starts successfully without
OPENAI_API_KEY✅ Better UX: Users can explore non-AI features immediately
✅ Graceful degradation: Clear messages when AI features are unavailable
✅ Backward compatibility: Existing configurations work unchanged
✅ Smart detection: Only affects OpenAI models, other providers unaffected
Testing Results
Technical Details
The solution implements Option 2 from the issue description with enhanced error handling:
OPENAI_API_KEYis missingAcceptance Criteria
OPENAI_API_KEYenvironment variableCloses #72