Troubleshooting Guide¶
Common issues and solutions for OSA community onboarding and operations.
Quick Diagnostic Checklist¶
Before diving into specific errors:
-
Validate your config:
-
Check environment variables:
-
Test API key:
-
Check server status:
Configuration Validation Errors¶
Error: YAML Syntax Error¶
Symptom:
Causes: - Incorrect indentation (must use spaces, not tabs) - Missing colon after key - Improper list formatting - Special characters not quoted
Solutions:
Check indentation:
# Wrong - using tabs
documentation:
- title: My Doc
# Correct - using spaces
documentation:
- title: My Doc
Quote special characters:
# Wrong - colon in unquoted string
description: HED: Event annotation
# Correct - quoted
description: "HED: Event annotation"
List formatting:
# Wrong - missing dash
cors_origins:
https://example.com
# Correct - with dash
cors_origins:
- https://example.com
Validation:
Error: Community ID must be kebab-case¶
Symptom:
Cause: Community ID contains uppercase letters, underscores, or invalid characters.
Solution:
# Wrong
id: MyProject
id: my_project
id: my.project
id: -myproject # Leading hyphen
# Correct
id: myproject
id: my-project
id: my-project-2024
Rules: - Lowercase letters only - Numbers allowed - Hyphens allowed (not leading/trailing) - No underscores, dots, or spaces
Error: Invalid CORS origin¶
Symptom:
Cause: CORS origin missing scheme or improperly formatted.
Solution:
# Wrong - missing scheme
cors_origins:
- example.com
- www.example.com
# Wrong - includes path
cors_origins:
- https://example.com/docs
# Correct
cors_origins:
- https://example.com
- https://www.example.com
- https://*.pages.dev
Common Mistakes: - Forgetting https:// prefix - Including path (/docs) - Including query string (?foo=bar) - Using * alone (not allowed)
Error: Preload requires source_url¶
Symptom:
Cause: Document configured with preload: true but missing source_url field.
Solution:
# Wrong - preload without source_url
documentation:
- title: Core Docs
url: https://example.com/docs
preload: true
# Correct - source_url provided
documentation:
- title: Core Docs
url: https://example.com/docs
source_url: https://raw.githubusercontent.com/org/repo/main/docs.md
preload: true
Why: Preloaded documents are fetched and embedded in the system prompt. The source_url must point to the raw markdown or text content.
Error: Repository must be in 'org/repo' format¶
Symptom:
Cause: GitHub repository missing organization prefix.
Solution:
# Wrong - missing org
github:
repos:
- hed-specification
# Correct - org/repo format
github:
repos:
- hed-standard/hed-specification
Error: Invalid DOI format¶
Symptom:
Cause: DOI includes URL prefix or doesn't match expected format.
Solution:
# Wrong - includes prefix
citations:
dois:
- https://doi.org/10.1234/example
- doi.org/10.1234/example
# Correct - DOI only
citations:
dois:
- 10.1234/example
Valid DOI Format: - Must start with 10. - Format: 10.xxxx/yyyy - No URL prefixes
API Key Issues¶
Warning: API key env var not set¶
Symptom:
Impact: - Assistant will fall back to platform API key - Costs billed to platform, not your community - Shared rate limits apply
Solution:
For local testing:
# Add to shell profile (~/.zshrc or ~/.bashrc)
echo 'export OPENROUTER_API_KEY_MYPROJECT="sk-or-v1-..."' >> ~/.zshrc
source ~/.zshrc
# Verify
echo $OPENROUTER_API_KEY_MYPROJECT
For production (server):
# Add to .env file
echo 'OPENROUTER_API_KEY_MYPROJECT="sk-or-v1-..."' >> .env
# Or add to environment
export OPENROUTER_API_KEY_MYPROJECT="sk-or-v1-..."
Verify:
uv run osa validate src/assistants/myproject/config.yaml
# Should show: "OPENROUTER_API_KEY_MYPROJECT is set"
Error: API key test failed (401 Unauthorized)¶
Symptom:
Causes: - API key is invalid or expired - Wrong key format - Key not activated on OpenRouter
Solution:
-
Verify key format:
-
Check key on OpenRouter:
- Visit https://openrouter.ai/keys
- Verify key exists and is active
-
Check usage limits not exceeded
-
Generate new key if needed:
- Go to https://openrouter.ai/keys
- Create new API key
-
Update environment variable
-
Test directly:
Error: API key test failed (403 Forbidden)¶
Symptom:
Cause: API key doesn't have necessary permissions or credits exhausted.
Solution:
- Check credits:
- Visit https://openrouter.ai/credits
-
Ensure account has credits available
-
Check key permissions:
- Some keys may be restricted to certain models
-
Verify key has access to models you want to use
-
Add credits:
- Add credits to your OpenRouter account
- Test again after credits added
Runtime Errors¶
Error: CORS policy blocked¶
Browser Console:
Access to fetch at 'https://api.osc.earth/osa/...' from origin 'https://mysite.com'
has been blocked by CORS policy
Cause: Your website origin not listed in cors_origins config.
Solution:
-
Add your origin to config:
-
Redeploy assistant (config changes require restart)
-
Verify origin exactly matches:
Common Issues: - Forgot www subdomain variant - http:// vs https:// mismatch - Port number missing (e.g., :3000) - Trailing slash in config (remove it)
Error: Widget not loading¶
Symptom: Widget icon doesn't appear or widget doesn't open.
Causes: 1. Script not loaded 2. Wrong community ID 3. API endpoint unreachable 4. JavaScript errors
Diagnosis:
-
Check browser console (F12 -> Console):
-
Verify script loads:
-
Check network tab:
- Widget.js should load (200 OK)
- API requests should succeed
Solutions:
Wrong community ID:
<!-- Wrong - ID doesn't match config -->
<script>
OSAWidget.init({
communityId: 'wrong-id' // Check this matches config.yaml
});
</script>
<!-- Correct -->
<script>
OSAWidget.init({
communityId: 'hed' // Must match config.yaml id field
});
</script>
Script placement:
<!-- Wrong - script in <head> before widget init -->
<head>
<script>
OSAWidget.init({ communityId: 'hed' });
</script>
<script src="https://api.osc.earth/osa/widget.js"></script>
</head>
<!-- Correct - load script first -->
<body>
<script src="https://api.osc.earth/osa/widget.js"></script>
<script>
OSAWidget.init({ communityId: 'hed' });
</script>
</body>
API endpoint:
// Check if API is reachable
fetch('https://api.osc.earth/osa/health')
.then(r => r.json())
.then(console.log);
// Should show: {status: "healthy"}
Error: Messages not getting responses¶
Symptom: Widget accepts input but shows loading spinner indefinitely.
Causes: 1. API key not configured 2. Network errors 3. Model timeout 4. Backend server down
Diagnosis:
- Check browser network tab:
- Look for failed API requests
- Check response status codes
-
Look for timeout errors
-
Check API health:
-
Check backend logs (if you have access):
Solutions:
API key missing: - Verify openrouter_api_key_env_var is set on server - Check env var exists: echo $OPENROUTER_API_KEY_XXX - Restart server after adding env var
Network errors: - Check firewall rules - Verify API endpoint accessible - Check DNS resolution
Timeouts: - May indicate model is slow or overloaded - Try different model (faster) - Check OpenRouter status
Deployment Issues¶
Error: Config file not found¶
Symptom:
Cause: Config file not in expected location or path incorrect.
Solution:
-
Check file exists:
-
Verify directory structure:
-
Check file name:
- Must be exactly
config.yaml - Lowercase, not
Config.yaml
Error: Assistant not discovered¶
Symptom: After deployment, osa myproject ask "test" returns:
Cause: Assistant not registered in registry.
Diagnosis:
-
Check discovery:
-
Check directory structure:
Solution:
-
Ensure config.yaml exists:
-
Restart server:
-
Check for validation errors:
Testing Issues¶
Error: Tests fail with import errors¶
Symptom:
Cause: Module not in Python path or not installed.
Solution:
-
Sync dependencies:
-
Run tests from repo root:
-
Check Python path:
Error: Tests fail with fixture errors¶
Symptom:
Cause: Using old pytest version or fixture not available.
Solution:
-
Update pytest:
-
Verify pytest version:
Performance Issues¶
Issue: Widget loads slowly¶
Symptoms: - Widget takes 3-5+ seconds to appear - First message slow to respond
Causes: 1. Large system prompt (too many preloaded docs) 2. Slow model 3. Network latency 4. Cold start (server sleeping)
Solutions:
Reduce preloaded docs:
# Before - 5 preloaded docs = slow
documentation:
- title: Doc 1
preload: true
- title: Doc 2
preload: true
# ... 3 more preloaded
# After - 1-2 critical docs only
documentation:
- title: Core Spec
preload: true
- title: API Ref
preload: false # Fetch on-demand
Use faster model:
# Before - Opus is slow but capable
default_model: anthropic/claude-opus-4.5
# After - Haiku is fast
default_model: anthropic/claude-haiku-4.5
default_model_provider: Cerebras # Route to fast provider
Check network:
Issue: High API costs¶
Symptoms: - OpenRouter bill higher than expected - Usage exceeded budget
Causes: 1. Expensive model (Opus) 2. Long conversations (context accumulation) 3. Many users 4. Preloaded docs increasing prompt size
Solutions:
Use cheaper model:
# Opus: $15/1M tokens
default_model: anthropic/claude-opus-4.5
# Haiku: $0.25/1M tokens (60x cheaper!)
default_model: anthropic/claude-haiku-4.5
Reduce preloaded docs: - Each preloaded doc adds to every request - Move to on-demand retrieval - Keep preloaded docs minimal
Monitor usage: - Check OpenRouter dashboard regularly - Set up budget alerts - Track usage by community ID
Cost Comparison: | Model | Cost (per 1M tokens) | Use Case | |-------|---------------------|----------| | Haiku | $0.25 | General Q&A | | Sonnet | $3.00 | Complex tasks | | Opus | $15.00 | Critical accuracy |
Widget Integration Issues¶
Issue: Widget appears but can't read page content¶
Symptom: Assistant says "I cannot access the current page content" when asked about page.
Cause: enable_page_context disabled or tool not available.
Solution:
Verify:
# Check config
grep enable_page_context src/assistants/myproject/config.yaml
# Should show: enable_page_context: true
Issue: Widget positioning problems¶
Symptom: Widget icon overlaps with page content or appears in wrong location.
Cause: CSS conflicts with your site's styles.
Solution:
Add custom CSS:
<style>
/* Adjust widget position */
#osa-widget-container {
bottom: 20px !important;
right: 20px !important;
z-index: 9999 !important;
}
</style>
Check for conflicts:
// In browser console
console.log(getComputedStyle(document.getElementById('osa-widget-container')));
Documentation Sync Issues¶
Error: Documentation fetch fails¶
Symptom: Assistant says "I couldn't retrieve that documentation."
Causes: 1. source_url unreachable 2. GitHub rate limit 3. URL changed/moved
Diagnosis:
# Test URL directly
curl -I https://raw.githubusercontent.com/org/repo/main/docs.md
# Should return 200 OK
Solutions:
URL moved:
# Update to new URL
documentation:
- title: My Doc
url: https://newsite.org/docs
source_url: https://raw.githubusercontent.com/org/repo/main/docs/newpath.md
GitHub rate limit: - Wait an hour for limit reset - Use GitHub token for higher limits - Move docs to CDN
HTTPS required:
# Wrong - HTTP not secure
source_url: http://example.com/docs.md
# Correct - HTTPS
source_url: https://example.com/docs.md
Getting Help¶
If you're still stuck after trying these solutions:
-
Check logs:
-
Run health check:
-
Validate config again:
-
File an issue:
- GitHub: https://github.com/OpenScience-Collective/osa/issues
-
Include:
- Error message (full text)
- Config file (sanitized, remove API keys!)
- Steps to reproduce
- Environment (OS, Python version)
-
Ask in discussions:
- https://github.com/OpenScience-Collective/osa/discussions
Prevention Checklist¶
Before deploying to production:
- Config validated locally (
osa validate) - API key tested (
--test-api-key) - CORS origins match production domains
- Documentation URLs verified (returns 200 OK)
- Widget tested on actual website
- Costs estimated based on expected usage
- Monitoring/alerts configured
- Team trained on troubleshooting basics
Common Error Messages Reference¶
Quick lookup table:
| Error | Section | Quick Fix |
|---|---|---|
| YAML syntax error | Config Validation | Check indentation, quotes |
| kebab-case | Config Validation | Use lowercase with hyphens |
| Invalid CORS origin | Config Validation | Add https:// prefix |
| preload requires source_url | Config Validation | Add source_url field |
| API key not set | API Keys | Export env var |
| 401 Unauthorized | API Keys | Check API key validity |
| CORS blocked | Runtime | Add origin to config |
| Widget not loading | Runtime | Check script, community ID |
| Config not found | Deployment | Check file path |
| Assistant not discovered | Deployment | Restart server |