fix(ingestion): address code review issues in api and watcher packages
- Strip internal error detail from 500 responses (leak prevention) - Add path containment assertion in /write handler - Use Go 1.22 method-prefixed mux routes for automatic 405 responses - Clarify watch_interval log when watcher not yet wired - Consolidate validation tests into table-driven TestIngest_Validation - Watcher: return nil after successful quarantine to avoid double-logging - Watcher: append timestamp suffix to processed dest if file already exists Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -55,19 +56,23 @@ func main() {
|
||||
_ = watchInterval
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/query", h.Query)
|
||||
mux.HandleFunc("/write", h.Write)
|
||||
mux.HandleFunc("/ingest", h.Ingest)
|
||||
mux.HandleFunc("/ingest-path", h.IngestPath)
|
||||
mux.HandleFunc("POST /query", h.Query)
|
||||
mux.HandleFunc("POST /write", h.Write)
|
||||
mux.HandleFunc("POST /ingest", h.Ingest)
|
||||
mux.HandleFunc("POST /ingest-path", h.IngestPath)
|
||||
|
||||
addr := ":" + port
|
||||
watchIntervalLog := "disabled"
|
||||
if watchInterval > 0 {
|
||||
watchIntervalLog = fmt.Sprintf("%ds (pending task11 wiring)", watchInterval)
|
||||
}
|
||||
logger.Info("ingestion server starting",
|
||||
"addr", addr,
|
||||
"brain_dir", brainDir,
|
||||
"llm_url", llmURL,
|
||||
"llm_model", llmModel,
|
||||
"chunk_size", chunkSize,
|
||||
"watch_interval_s", watchInterval,
|
||||
"watch_interval", watchIntervalLog,
|
||||
)
|
||||
if err := http.ListenAndServe(addr, mux); err != nil {
|
||||
logger.Error("server stopped", "err", err)
|
||||
|
||||
Reference in New Issue
Block a user