Error Reference¶
Comprehensive reference for Crystalyse error codes, messages, and troubleshooting guidance.
Overview¶
Crystalyse provides detailed error information to help diagnose and resolve issues quickly. Errors are categorised by source and include specific guidance for resolution.
Error Categories¶
Exit Codes¶
Standard process exit codes used by Crystalyse:
| Code | Category | Description |
|---|---|---|
| 0 | Success | Command completed successfully |
| 1 | General Error | Unspecified error occurred |
| 2 | Invalid Input | Invalid command or arguments |
| 3 | Configuration Error | Configuration file or settings issue |
| 4 | API Error | OpenAI API connection or authentication issue |
| 5 | MCP Server Error | MCP server connection or tool failure |
| 6 | Analysis Timeout | Analysis exceeded time limits |
| 7 | Memory Error | Insufficient memory for operation |
| 8 | File Error | File system access or permission issue |
Common Error Types¶
API Errors¶
Missing API Key¶
Cause: OPENAI_API_KEY environment variable not set Solution:
export OPENAI_API_KEY="sk-your-key-here"
echo 'export OPENAI_API_KEY="sk-your-key-here"' >> ~/.bashrc
Invalid API Key¶
Cause: API key is malformed or expired Solution: 1. Verify key format starts with sk- 2. Check key hasn't expired 3. Generate new key from OpenAI dashboard
API Rate Limiting¶
Cause: Too many requests to OpenAI API Solution: 1. Wait for rate limit reset 2. Consider upgrading API plan 3. Use creative mode for faster queries
API Connection Timeout¶
Cause: Network connectivity or API service issues Solution: 1. Check internet connection 2. Verify API service status 3. Retry with longer timeout
MCP Server Errors¶
Server Not Found¶
Cause: MCP server not installed or not in PATH Solution:
pip install -e ./chemistry-unified-server
pip install -e ./chemistry-creative-server
pip install -e ./visualization-mcp-server
Server Connection Failed¶
Cause: Server process failed to start or crashed Solution: 1. Check server dependencies installed 2. Verify Python environment activated 3. Review server logs for details
Tool Execution Failed¶
Cause: Specific tool within MCP server encountered error Solution: 1. Check tool-specific dependencies 2. Verify input format and constraints 3. Review detailed error message
Configuration Errors¶
Invalid Configuration File¶
Cause: Malformed YAML in configuration file Solution: 1. Check YAML syntax and indentation 2. Validate file with YAML parser 3. Compare with reference configuration
Missing Configuration¶
Cause: Configuration file missing or wrong location Solution: 1. Create default configuration 2. Check file permissions 3. Verify file path
Invalid Configuration Values¶
Cause: Configuration contains invalid values Solution: 1. Check valid options in documentation 2. Update configuration with correct values 3. Validate configuration syntax
Analysis Errors¶
Analysis Timeout¶
Cause: Analysis taking too long to complete Solution: 1. Use creative mode for faster results 2. Reduce structure samples 3. Simplify query or break into parts
Insufficient Memory¶
Cause: System running out of RAM during analysis Solution: 1. Reduce batch size and structure samples 2. Close other memory-intensive applications 3. Use systems with more RAM
Invalid Query¶
Cause: Query format not recognised by analysis system Solution: 1. Use clear, specific materials terminology 2. Check query examples in documentation 3. Break complex queries into simpler parts
Session Errors¶
Session Not Found¶
Cause: Session doesn't exist or incorrect user/session ID Solution: 1. List available sessions: crystalyse sessions -u researcher 2. Check session ID spelling 3. Verify user ID is correct
Session Database Locked¶
Cause: Another Crystalyse process accessing database Solution: 1. Wait for other process to complete 2. Check for hung processes 3. Restart if necessary
Session Corruption¶
Cause: Database file corrupted or incomplete Solution: 1. Backup existing database if possible 2. Reset database: rm ~/.crystalyse/sessions.db 3. Start fresh sessions
Installation Errors¶
Python Version Incompatible¶
Cause: Python version too old Solution:
Dependency Installation Failed¶
Cause: Package installation issues Solution: 1. Update pip: pip install --upgrade pip 2. Check internet connection 3. Install in clean environment
Import Errors¶
Cause: Package not installed or wrong environment Solution: 1. Activate correct environment: conda activate crystalyse 2. Reinstall package: pip install -e . 3. Check Python path
Error Diagnosis¶
Verbose Mode¶
Enable detailed error information:
Debug Mode¶
Enable comprehensive debugging:
Log Analysis¶
Check log files for detailed error information:
# View recent logs
tail -f ~/.crystalyse/crystalyse.log
# Search for specific errors
grep "ERROR" ~/.crystalyse/crystalyse.log
Error Recovery¶
Automatic Recovery¶
Crystalyse includes automatic recovery for:
- Temporary API failures: Automatic retry with exponential backoff
- MCP server restart: Automatic server restart on failure
- Memory management: Automatic cleanup of temporary files
Manual Recovery¶
Reset Configuration¶
# Backup current config
cp ~/.crystalyse/config.yaml ~/.crystalyse/config.yaml.backup
# Reset to defaults
rm ~/.crystalyse/config.yaml
crystalyse config show # Generates default config
Clear Cache¶
# Clear analysis cache
rm -rf ~/.crystalyse/cache/*
# Clear session data (caution: loses conversation history)
rm ~/.crystalyse/sessions.db
Restart MCP Servers¶
# MCP servers restart automatically, but can be forced by:
# Simply running a new command - servers will restart if needed
crystalyse config show
Reporting Errors¶
Information to Include¶
When reporting errors, provide:
- Error message: Complete error text
- Command used: Exact command that caused error
- Environment: Operating system, Python version
- Configuration: Output of
crystalyse config show - Logs: Relevant log entries
Example Error Report¶
Environment:
- OS: Ubuntu 22.04
- Python: 3.11.5
- Crystalyse: v1.0.0
Command:
crystalyse analyse "Find battery materials" --mode rigorous
Error:
Error: MCP server 'chemistry_unified' connection failed
Configuration:
chemistry_unified: ❌ Unavailable
chemistry_creative: ✅ Available
visualization: ✅ Available
Logs:
2025-01-15 14:30:25 ERROR: Failed to start chemistry_unified server
2025-01-15 14:30:25 ERROR: ModuleNotFoundError: No module named 'smact'
Prevention Strategies¶
Environment Management¶
Use isolated environments:
Configuration Validation¶
Regularly validate configuration:
Resource Monitoring¶
Monitor system resources:
API Key Management¶
Secure API key handling:
# Set in shell profile
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc
# Check key is set
echo $OPENAI_API_KEY | head -c 10
Error Code Reference¶
Complete Error Code List¶
| Code | Category | Message Pattern | Severity |
|---|---|---|---|
| E001 | API | "OpenAI API key not found" | Critical |
| E002 | API | "Authentication failed" | Critical |
| E003 | API | "Rate limit exceeded" | Warning |
| E004 | API | "Request timeout" | Warning |
| E101 | MCP | "MCP server not found" | Critical |
| E102 | MCP | "Server connection failed" | Critical |
| E103 | MCP | "Tool execution failed" | Error |
| E201 | Config | "Invalid configuration file" | Error |
| E202 | Config | "Configuration file not found" | Warning |
| E203 | Config | "Invalid configuration values" | Error |
| E301 | Analysis | "Analysis timeout" | Warning |
| E302 | Analysis | "Insufficient memory" | Error |
| E303 | Analysis | "Invalid query" | Error |
| E401 | Session | "Session not found" | Error |
| E402 | Session | "Database locked" | Warning |
| E403 | Session | "Session corrupted" | Critical |
See Also¶
- Installation Guide - Setup troubleshooting
- CLI Reference - Command usage
- Configuration Reference - Configuration options