Add fail-fast on init for missing provider credentials

This commit is contained in:
2026-03-06 21:31:51 +00:00
parent 610b6c3367
commit 89c7e3ac85
14 changed files with 398 additions and 20 deletions

View File

@@ -155,6 +155,11 @@ func main() {
// Register admin endpoints if enabled
if cfg.Admin.Enabled {
// Check if frontend dist exists
if _, err := os.Stat("internal/admin/dist"); os.IsNotExist(err) {
log.Fatalf("admin UI enabled but frontend dist not found")
}
buildInfo := admin.BuildInfo{
Version: "dev",
BuildTime: time.Now().Format(time.RFC3339),
@@ -348,23 +353,39 @@ func initConversationStore(cfg config.ConversationConfig, logger *slog.Logger) (
return conversation.NewMemoryStore(ttl), "memory", nil
}
}
type responseWriter struct {
http.ResponseWriter
statusCode int
bytesWritten int
wroteHeader bool
}
func (rw *responseWriter) WriteHeader(code int) {
if rw.wroteHeader {
return
}
rw.wroteHeader = true
rw.statusCode = code
rw.ResponseWriter.WriteHeader(code)
}
func (rw *responseWriter) Write(b []byte) (int, error) {
if !rw.wroteHeader {
rw.wroteHeader = true
rw.statusCode = http.StatusOK
}
n, err := rw.ResponseWriter.Write(b)
rw.bytesWritten += n
return n, err
}
func (rw *responseWriter) Flush() {
if flusher, ok := rw.ResponseWriter.(http.Flusher); ok {
flusher.Flush()
}
}
func loggingMiddleware(next http.Handler, logger *slog.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()