Overview
This guide covers common errors, their causes, and solutions when using DocuGen AI.API Key Errors
ValueError: GEMINI_API_KEY is required
ValueError: GEMINI_API_KEY is required
RuntimeError: google-genai is not installed
RuntimeError: google-genai is not installed
Error Message:Cause:The Solutions:
google-genai package is not installed. This is checked in GeminiClient._build_client() (docugen/api/gemini_client.py:40):If you installed DocuGen with
pip install docugen, the dependency should be included. This error typically occurs in development or when dependencies are manually managed.RuntimeError: Gemini API call failed
RuntimeError: Gemini API call failed
Error Message:Cause:The Gemini API request failed. This can happen in Common Causes & Solutions:
Debugging:
GeminiClient.generate_markdown() (docugen/api/gemini_client.py:86):| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid API key | Verify your API key at Google AI Studio |
429 Too Many Requests | Rate limit exceeded | Wait and retry, or upgrade your quota |
400 Bad Request | Invalid model name | Check model name (default: gemini-3.1-flash-lite-preview) |
503 Service Unavailable | Temporary outage | Retry after a few minutes |
RuntimeError: Gemini response did not include text content
RuntimeError: Gemini response did not include text content
Error Message:Cause:The API returned a response without text content. This is detected in Possible Reasons:
GeminiClient._extract_text() (docugen/api/gemini_client.py:75):- Content filtered by safety settings
- Model returned empty response
- API returned unexpected response structure
-
Check for content filtering:
- Simplify input: Try with minimal metadata to isolate the issue
-
Try different model:
Parsing Errors
SyntaxError during file parsing
SyntaxError during file parsing
Error Message:Cause:A Python file contains syntax errors. Detected in Solutions:
parse_file() (docugen/core/parser.py:115):DocuGen continues processing other files when it encounters a syntax error. The error is recorded in the
errors list but doesn’t stop the entire scan.Cannot read file: OSError
Cannot read file: OSError
Error Message:Cause:File cannot be read due to permissions or I/O errors. Caught in Solutions:
parse_file() (docugen/core/parser.py:107):-
Check permissions:
-
Verify file exists:
-
Exclude from scan:
File Discovery Issues
FileNotFoundError: Path does not exist
FileNotFoundError: Path does not exist
Error Message:Cause:The specified path doesn’t exist. Raised in Solutions:
scan_python_files() (docugen/core/scanner.py:98):-
Verify path:
-
Use correct path:
No Python files found
No Python files found
Symptom:
scan_python_files() returns an empty list.Possible Causes:-
No
.pyfiles in directory- Verify files exist:
find /path/to/project -name "*.py"
- Verify files exist:
-
All files ignored by .gitignore
- Review
.gitignorepatterns - Test with empty
.gitignore
- Review
-
Files in default-ignored directories
- Check if files are in
__pycache__,.venv, etc.
- Check if files are in
Template Errors
TemplateNotFound
TemplateNotFound
Error Message:Cause:The specified template file doesn’t exist in the template directory.Solutions:
-
Verify template location:
-
Use default template:
-
Provide full path:
TemplateSyntaxError
TemplateSyntaxError
Error Message:Cause:Invalid Jinja2 syntax in template file.Common Mistakes:
Solutions:
| Error | Wrong | Correct |
|---|---|---|
| Missing closing tag | {% if x %} | {% if x %}...{% endif %} |
| Invalid filter | {{ x | invalid }} | {{ x | upper }} |
| Wrong delimiter | {{{ variable }}} | {{ variable }} |
| Unclosed quote | {{ "text }} | {{ "text" }} |
-
Validate syntax:
- Test incrementally: Start with a minimal template and add complexity gradually
UndefinedError: variable not defined
UndefinedError: variable not defined
Error Message:Cause:Template references a variable not in the context.Solutions:
-
Add missing variable:
-
Use conditional checks:
-
Provide default:
Performance Issues
Slow scanning on large repositories
Slow scanning on large repositories
Symptom:
scan_python_files() takes a long time on large codebases.Causes:- Many files to scan
- Complex
.gitignorerules - Slow filesystem (network drives)
-
Improve .gitignore:
-
Scan specific subdirectory:
-
Monitor progress:
API timeout or rate limiting
API timeout or rate limiting
Symptom:Gemini API calls fail with timeout or rate limit errors.Solutions:
-
Batch processing:
-
Reduce input size:
- Upgrade quota: Visit Google AI Studio to increase rate limits
Getting Help
Check Logs
Enable verbose logging to debug issues:
Minimal Reproduction
Create a minimal test case:
GitHub Issues
Report bugs with:
- Error message
- Python version
- DocuGen version
- Minimal reproduction
Community Support
Ask questions:
- Stack Overflow (tag:
docugen) - GitHub Discussions
- Discord community
