Troubleshooting¶
Solutions to common issues.
Setup Issues¶
Import Errors¶
Problem: ModuleNotFoundError: No module named 'pydantic'
Solution: Install dependencies:
Test Failures¶
Problem: Tests fail after fresh clone
Solution:
Type Errors¶
Problem: Pyright reports errors
Solution:
Pre-commit Hook Failures¶
Problem: Hooks fail on commit
Solution:
# Run manually to see errors
pre-commit run --all-files
# Fix issues
make format
make lint-fix
# Skip hooks (not recommended)
git commit --no-verify
Runtime Issues¶
Server Won't Start¶
Problem: FileNotFoundError: models.py not found
Solution: Use correct path:
# Relative path
mockapi-server serve --models ./path/to/models.py
# Absolute path
mockapi-server serve --models /full/path/to/models.py
# Verify file exists
ls -la models.py
Problem: ModuleNotFoundError: No module named 'pydantic'
Solution:
Problem: Port already in use
Solution: Use different port or kill process:
# Use different port
mockapi-server serve --models models.py --port 8000
# Find and kill process
lsof -i :3000
kill -9 <PID>
Validation Errors¶
Problem: 422 validation errors when creating/updating
Solution: Ensure request matches Pydantic model exactly:
All required fields must be present in request. Check /docs for exact schema.
CORS Errors¶
Problem: Browser shows CORS policy errors
Solution: Enable CORS in config:
# mockapi-server.yml
cors_enabled: true
cors_origins:
- "*" # Allow all (dev only)
- "http://localhost:3001" # Specific origin
Foreign Key Issues¶
Problem: author_id references non-existent users
Solution: Use --generate-data flag for automatic relationship handling:
Or create parent records first when manually creating data:
# 1. Create user first
curl -X POST http://localhost:3000/api/v1/users ...
# 2. Then create post with valid author_id
curl -X POST http://localhost:3000/api/v1/posts \
-d '{"author_id": 1, ...}'
Build/Release Issues¶
Build Fails¶
Problem: uv build fails
Solution:
Upload Fails¶
Problem: twine upload fails
Solution: Check PyPI credentials:
# Verify ~/.pypirc
cat ~/.pypirc
# Regenerate token on PyPI if needed
# Try verbose upload
uv run twine upload dist/* --verbose
Tag Conflicts¶
Problem: Tag already exists
Solution:
# Delete local tag
git tag -d v0.1.0
# Delete remote tag
git push origin --delete v0.1.0
# Re-create
git tag -a v0.1.0 -m "Release v0.1.0"
git push origin v0.1.0
Getting Help¶
Still stuck? Try:
- Check FAQ for common questions
- Search existing issues
- Open a new issue with:
- Error message
- Steps to reproduce
- Environment (OS, Python version)
- Relevant code snippets