plandex-ai/plandex · error
error getting custom models: %v
Error message
error getting custom models: %v
What it means
GetPlanSettings first calls GetApiCustomModels(plan.OrgId) to load the org's custom models/packs/providers. If that fails, the error is wrapped as this message. The failure is in the custom-models lookup, not in reading plan settings itself.
Source
Thrown at app/server/db/settings_helpers.go:23
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"
"time"
shared "plandex-shared"
"github.com/jmoiron/sqlx"
)
func GetPlanSettings(plan *Plan) (settings *shared.PlanSettings, err error) {
planDir := getPlanDir(plan.OrgId, plan.Id)
settingsPath := filepath.Join(planDir, "settings.json")
result, err := GetApiCustomModels(plan.OrgId)
if err != nil {
return nil, fmt.Errorf("error getting custom models: %v", err)
}
defer func() {
if settings != nil {
settings.Configure(result.CustomModelPacks, result.CustomModels, result.CustomProviders, os.Getenv("PLANDEX_CLOUD") != "")
}
}()
bytes, err := os.ReadFile(settingsPath)
if os.IsNotExist(err) || len(bytes) == 0 {
log.Printf("GetPlanSettings - no settings file found for plan %s - checking org defaults", plan.Id)
// see if org has default settings
defaultSettings, err := GetOrgDefaultSettings(plan.OrgId)
if err != nil {
return nil, fmt.Errorf("error getting org default settings: %v", err)
}View on GitHub (pinned to e2d772072e)
Solutions
- Unwrap the inner error — fix the underlying GetApiCustomModels failure first.
- Verify orgId is valid and its custom models data exists and parses.
- Check database connectivity/health if the custom models store is DB-backed.
- Restore or rebuild the org's custom models config from backup.
Example fix
// before
settings, err := db.GetPlanSettings(plan)
// after
settings, err := db.GetPlanSettings(plan)
if err != nil && strings.Contains(err.Error(), "error getting custom models") {
log.Printf("custom models lookup failed for org %s: %v", plan.OrgId, err)
} Defensive patterns
Strategy: fallback
Try / catch
settings, err := GetPlanSettings(plan)
if err != nil && strings.Contains(err.Error(), "error getting custom models") {
log.Printf("proceeding with builtin defaults; custom models unavailable: %v", err)
settings = &shared.PlanSettings{ModelPackName: shared.DefaultModelPack.Name}
} Prevention
- Verify the org's custom models data loads (via the equivalent API) before plan operations.
- Monitor DB connectivity health if custom models are DB-backed.
- Validate orgId at request boundaries.
When it happens
Trigger: Calling GetPlanSettings (directly or via LoadContexts, UpdateContexts, TellPlanHandler, BuildPlanHandler, etc.) when GetApiCustomModels fails for the org — e.g. the org's custom models store is missing/corrupt, or a DB (sqlx) error occurs during that lookup.
Common situations: Corrupted or missing custom models data for the org; database connectivity problems; an org id that doesn't exist in the models store.
Related errors
- error copying settings: %v
- error getting org default settings: %v
- connection to plan stream timed out due to missing heartbeat
- error loading accounts: %v
- error signing in to new account: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/99683a975cbf90ff.
Report an issue: GitHub.