Skip to content

fix: replace panic() with log.Fatalf() in init functions#338

Open
1Ckpwee wants to merge 1 commit into
plandex-ai:mainfrom
1Ckpwee:fix/replace-panics-with-errors
Open

fix: replace panic() with log.Fatalf() in init functions#338
1Ckpwee wants to merge 1 commit into
plandex-ai:mainfrom
1Ckpwee:fix/replace-panics-with-errors

Conversation

@1Ckpwee

@1Ckpwee 1Ckpwee commented Apr 8, 2026

Copy link
Copy Markdown

Summary

Fixes #337

Replaces panic() calls with log.Fatalf() in three init() functions. Panics produce noisy goroutine stack traces that obscure the actual error. log.Fatalf() logs a clear message and exits cleanly.

Changes

  • app/shared/ai_models_available.go: 10 panic()log.Fatalf() in model validation loop, with "model validation failed: " prefix
  • app/server/db/fs.go: panic(fmt.Errorf(...))log.Fatalf(...) for home dir detection
  • app/server/db/git.go: panic(fmt.Errorf(...))log.Fatalf(...) for git availability check

Rationale

Since these are init() functions (cannot return errors), log.Fatalf() is the appropriate replacement — it provides a clean error message and os.Exit(1) instead of a panic trace.

Test plan

  • Verify compilation: go build ./...
  • Trigger a validation failure (e.g., empty model description) and confirm clean error output
  • Normal startup should be unaffected

Replace panic() with log.Fatalf() in package init functions for cleaner
error output on startup failures. Panic produces a goroutine stack trace
that obscures the actual error, while log.Fatalf provides a clear message
and clean exit.

Changes:
- app/shared/ai_models_available.go: replace 10 panic() calls in model
  validation with log.Fatalf() and add descriptive prefixes
- app/server/db/fs.go: replace panic in home dir lookup with log.Fatalf
- app/server/db/git.go: replace panic in git availability check with log.Fatalf

Fixes plandex-ai#337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace panic() with error returns in model validation init

1 participant