fix(server): do not return database errors from the skill endpoints

Recent skill calls and missing-skill stats put pgx text in the HTTP body.
The server now logs that error and returns a fixed message.
This commit is contained in:
Coff0xc
2026-11-21 19:54:56 +00:00
parent 5bed53b6ae
commit 371ee1370b
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b
### Fixed
- **Skill endpoints no longer return database driver text**: a failure loading skill usage or missing-skill stats is logged on the server and the client receives a fixed message.
- **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450).
## [0.7.0] - 2026-11-21
+4 -2
View File
@@ -1227,7 +1227,8 @@ func (s *Server) fsSkillUsage(w http.ResponseWriter, r *http.Request) {
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
calls, err := pg.RecentSkillCalls(name, limit)
if err != nil {
writeErr(w, 500, err.Error())
log.Printf("[skills] recent calls for %s: %v", name, err)
writeErr(w, 500, "failed to load skill usage")
return
}
writeJSON(w, 200, map[string]any{"calls": calls})
@@ -1243,7 +1244,8 @@ func (s *Server) fsMissingSkills(w http.ResponseWriter, r *http.Request) {
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
missing, err := pg.MissingSkillStats(limit)
if err != nil {
writeErr(w, 500, err.Error())
log.Printf("[skills] missing skills: %v", err)
writeErr(w, 500, "failed to load missing skills")
return
}
writeJSON(w, 200, map[string]any{"missing": missing})