Replace panic() with error returns in model validation init
Author: 1CkpweeCreated Apr 8, 2026Updated Apr 8, 2026
Problem
In app/shared/ai_models_available.go, the init() function uses 12 panic() calls to validate model configurations at startup (around lines 667-711). If any model config is incomplete — e.g., missing a description or default max tokens — the entire application crashes immediately without any opportunity for graceful error handling or user-friendly messaging.
Example pattern:
if modelConfig.Description == "" {
panic("...")
}This is especially problematic because:
- Users who add custom models or modify configs get an opaque crash with no recovery path
- The panic trace is not user-friendly — it shows Go internals rather than actionable guidance
- It prevents partial startup (e.g., skipping a misconfigured model but proceeding with valid ones)
Similarly, app/server/db/fs.go:15 and app/server/db/git.go:28 panic during init if the home directory can't be found or git isn't installed, rather than returning errors.
Proposed solution
- Replace
panic()calls with a validation function that returnserror - Call validation at server startup, log warnings for invalid models, and skip them gracefully
- For critical dependencies (git, home dir), return a clear error message at startup rather than panicking
This would make Plandex more robust for self-hosted deployments where environment setup may vary.
Source: plandex-ai/plandex