v0.253.0 — errors carry the key of the sentence they are (R-557 slice 2 release B)
gates / gates (push) Successful in 24s

179 Hungarian sentences were built deep inside a package with fmt.Errorf and printed by
whoever caught them: too late to translate where they are shown, too early where they are
made. Every one now carries its key across that gap. ZERO Hungarian error literals remain.

util.MsgError does three things at once, each earned:
  - Error() is the Hungarian, byte for byte, so every un-converted printer is unchanged;
  - errors.Is answers for the kind AND for a wrapped cause (KindErrorf dropped the cause);
  - an error ARGUMENT renders recursively, so "formázás sikertelen: %w" translates whole.
A foreign error — restic, docker, ssh, the stdlib — prints verbatim. It is not ours.

76 display sites go through errText, and TestNoErrErrorInPageOutput convicts any that do
not. memoryVerdict returns an error rather than a sentence, so the deploy's 409 and the
household's language come from one value; UpdateRefusal gained a Cause to carry it.

Plurals, one rule, stated once: a key with .one/.other takes its COUNT first. Not a
per-call-site flag — the producer somebody forgot would read "3 app is not running". The
guard caught a real key collision (alert.deadapp.one) the day the rule landed.

TWO DEFECTS FOUND IN MY OWN TOOLING, recorded rather than quietly fixed. The bulk converter
silently dropped multi-line concatenations, damaging 7 producers — and the parity gate could
not see it, because every surviving fragment WAS a real base literal while the CALL had lost
text; two behaviour tests caught it. And the counting script was case-sensitive, so it said
"0 left" while five remained.

MinAgent: 0.131.0 (unchanged). No hub release needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-09-18 11:44:30 +02:00
parent 5270bad76e
commit 7c05b59708
70 changed files with 1853 additions and 377 deletions
+3 -3
View File
@@ -68,7 +68,7 @@ func (r *Router) geoUpdateSettings(w http.ResponseWriter, req *http.Request) {
if err := r.sett.SetGeoRestriction(geo); err != nil {
r.logger.Printf("[ERROR] [api] Failed to save geo settings: %v", err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -157,7 +157,7 @@ func (r *Router) geoSetAppOverride(w http.ResponseWriter, req *http.Request, app
override := &settings.AppGeoOverride{AllowedCountries: body.AllowedCountries}
if err := r.sett.SetGeoAppOverride(appName, override); err != nil {
r.logger.Printf("[ERROR] [api] Failed to save geo override for %s: %v", appName, err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -183,7 +183,7 @@ func (r *Router) geoRemoveAppOverride(w http.ResponseWriter, req *http.Request,
if err := r.sett.RemoveGeoAppOverride(appName); err != nil {
r.logger.Printf("[ERROR] [api] Failed to remove geo override for %s: %v", appName, err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
+7
View File
@@ -4,6 +4,7 @@ import (
"net/http"
"gitea.dooplex.hu/admin/felhom-controller/internal/i18n"
"gitea.dooplex.hu/admin/felhom-controller/internal/util"
)
// ── The JSON answers follow the language too (v0.252.0, slice 2 — R-557) ───────────────────────
@@ -66,6 +67,12 @@ func (r *Router) msgLang(lang, key string, a ...interface{}) string {
return b.Msgf(lang, key, a...)
}
// errText renders an error in the request's language: its bundle message when it carries one, its own
// text otherwise (restic, docker, ssh and the Go stdlib print verbatim — that text is not ours).
func (r *Router) errText(req *http.Request, err error) string {
return util.ErrText(r.langFor(req), err)
}
// countryName returns a country's name in lang, falling back to the name the cloudflare table
// carries when the bundle has no entry for the code.
//
+20 -20
View File
@@ -358,11 +358,11 @@ func (r *Router) listStacks(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: r.stackMgr.GetStacks()})
}
func (r *Router) rescanStacks(w http.ResponseWriter, _ *http.Request) {
func (r *Router) rescanStacks(w http.ResponseWriter, req *http.Request) {
r.logger.Printf("[INFO] [api] Manual stack rescan requested")
if err := r.stackMgr.ScanStacks(); err != nil {
r.logger.Printf("[ERROR] [api] Stack rescan failed: %v", err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
stackCount := len(r.stackMgr.GetStacks())
@@ -382,10 +382,10 @@ func (r *Router) getStack(w http.ResponseWriter, _ *http.Request, name string) {
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: stack})
}
func (r *Router) getDeployFields(w http.ResponseWriter, _ *http.Request, name string) {
func (r *Router) getDeployFields(w http.ResponseWriter, req *http.Request, name string) {
meta, appCfg, err := r.stackMgr.GetDeployFields(name)
if err != nil {
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -490,7 +490,7 @@ func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name stri
if err != nil {
r.logger.Printf("[ERROR] [api] Deploy failed for %s: %v", name, err)
// R-553 — the status code comes from the refusal's KIND (deployStatusFor), never from its words.
writeJSON(w, deployStatusFor(err), apiResponse{OK: false, Error: err.Error()})
writeJSON(w, deployStatusFor(err), apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -698,7 +698,7 @@ func (r *Router) actionStack(w http.ResponseWriter, req *http.Request, action, n
if strings.Contains(err.Error(), "not found") {
status = http.StatusNotFound
}
writeJSON(w, status, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, status, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -738,7 +738,7 @@ func (r *Router) updateOptionalConfig(w http.ResponseWriter, req *http.Request,
if err := r.stackMgr.UpdateOptionalConfig(name, body.Values); err != nil {
r.logger.Printf("[ERROR] [api] Optional config update failed for %s: %v", name, err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -783,7 +783,7 @@ func (r *Router) toggleIntegration(w http.ResponseWriter, req *http.Request, pro
state, err := r.integrationMgr.Toggle(req.Context(), provider, target, body.Enabled)
if err != nil {
r.logger.Printf("[ERROR] [api] Integration toggle failed for %s:%s: %v", provider, target, err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -807,22 +807,22 @@ func (r *Router) getStackLogs(w http.ResponseWriter, req *http.Request, name str
output, err := r.stackMgr.GetLogs(name, lines)
if err != nil {
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: map[string]string{"logs": output}})
}
func (r *Router) getStackHDDData(w http.ResponseWriter, _ *http.Request, name string) {
func (r *Router) getStackHDDData(w http.ResponseWriter, req *http.Request, name string) {
resp, err := r.stackMgr.GetStackHDDData(name)
if err != nil {
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: resp})
}
func (r *Router) getStackBackupData(w http.ResponseWriter, _ *http.Request, name string) {
func (r *Router) getStackBackupData(w http.ResponseWriter, req *http.Request, name string) {
if name == "" {
writeJSON(w, http.StatusBadRequest, apiResponse{OK: false, Error: "invalid stack name"})
return
@@ -840,7 +840,7 @@ func (r *Router) getStackBackupData(w http.ResponseWriter, _ *http.Request, name
resp, err := r.stackMgr.GetStackBackupData(name, nsRoot, mirrors)
if err != nil {
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: resp})
@@ -901,7 +901,7 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
if strings.Contains(err.Error(), "not deployed") || strings.Contains(err.Error(), "still running") {
status = http.StatusConflict
}
writeJSON(w, status, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, status, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -982,7 +982,7 @@ func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name stri
if strings.Contains(err.Error(), "not orphaned") || strings.Contains(err.Error(), "still running") {
status = http.StatusConflict
}
writeJSON(w, status, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, status, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -1166,7 +1166,7 @@ func (r *Router) metricsSystem(w http.ResponseWriter, req *http.Request) {
samples, err := r.metricsStore.QuerySystemMetrics(from, to, resolution)
if err != nil {
r.logger.Printf("[ERROR] [api] Failed to query system metrics: %v", err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -1194,7 +1194,7 @@ func (r *Router) metricsSystem(w http.ResponseWriter, req *http.Request) {
}})
}
func (r *Router) metricsContainerSummary(w http.ResponseWriter, _ *http.Request) {
func (r *Router) metricsContainerSummary(w http.ResponseWriter, req *http.Request) {
if r.metricsStore == nil {
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: []interface{}{}})
return
@@ -1203,7 +1203,7 @@ func (r *Router) metricsContainerSummary(w http.ResponseWriter, _ *http.Request)
summary, err := r.metricsStore.QueryContainerSummary()
if err != nil {
r.logger.Printf("[ERROR] [api] Failed to query container summary: %v", err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -1222,7 +1222,7 @@ func (r *Router) metricsContainer(w http.ResponseWriter, req *http.Request, name
samples, err := r.metricsStore.QueryContainerMetrics(name, from, to, resolution)
if err != nil {
r.logger.Printf("[ERROR] [api] Failed to query container metrics for %s: %v", name, err)
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
@@ -1342,7 +1342,7 @@ func (r *Router) selfupdateTrigger(w http.ResponseWriter, req *http.Request) {
return
}
if err := r.updater.TriggerUpdate("manual"); err != nil {
writeJSON(w, http.StatusConflict, apiResponse{OK: false, Error: err.Error()})
writeJSON(w, http.StatusConflict, apiResponse{OK: false, Error: r.errText(req, err)})
return
}
r.logger.Println("[INFO] [api] Manual self-update triggered")