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
+35 -35
View File
@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"gitea.dooplex.hu/admin/felhom-controller/internal/util"
"net/http"
"os"
"path"
@@ -49,7 +49,7 @@ var validFSTypes = map[string]bool{"ext4": true, "xfs": true}
func mountWhere(name string) (string, error) {
name = strings.TrimSpace(name)
if !mountNameRe.MatchString(name) {
return "", fmt.Errorf("érvénytelen csatlakoztatási név (csak betűk, számok, _ és - engedélyezett)")
return "", util.MsgError("err.web.ervenytelen_csatlakoztatasi_nev_csak_betuk_szamok")
}
return "/mnt/" + name, nil
}
@@ -116,7 +116,7 @@ func (s *Server) runStorageInit(ctx context.Context, agent diskAgent, device, fs
}
}
if !validFSTypes[fstype] {
return storageInitResult{}, fmt.Errorf("nem támogatott fájlrendszer: %q (ext4 vagy xfs)", fstype)
return storageInitResult{}, util.MsgError("err.web.nem_tamogatott_fajlrendszer_ext4_vagy_xfs", fstype)
}
// 1. Format — the AGENT inspects the device and tiers it by role. A data-bearing user-data device
// is allowed only with the customer's confirmation bound to its durable id; system/backup needs
@@ -135,7 +135,7 @@ func (s *Server) runStorageInit(ctx context.Context, agent diskAgent, device, fs
return res, nil // STOP — no bypass; the UI surfaces Opsign.
}
if err != nil && !isAgentTimeout(err) {
return storageInitResult{}, fmt.Errorf("formázás sikertelen: %w", err)
return storageInitResult{}, util.MsgError("err.web.formazas_sikertelen", err)
}
if !fr.Formatted {
// A slow mkfs (e.g. a large USB) outran the agent client's 15 s timeout — the agent runs the
@@ -152,14 +152,14 @@ func (s *Server) runStorageInit(ctx context.Context, agent diskAgent, device, fs
setP(storageInitPhaseMounting)
uuid := resolveEnrollUUID(ctx, agent, device)
if uuid == "" {
return storageInitResult{}, fmt.Errorf("formázás kész, de az új fájlrendszer-azonosító nem feloldható — frissítsen és használja a Csatolás funkciót")
return storageInitResult{}, util.MsgError("err.web.formazas_kesz_de_az_uj_fajlrendszer")
}
// 3. Mount (benign assign) at the raw /mnt/<name>. 4. Bind felhom-data under the shared parent FIRST
// (intermediary model) so the drive's STABLE path is live in the guest, THEN register + skeleton there
// (the controller can only see/write the drive at the stable path post-attach). 5. Register the stable
// path — that is what apps' HDD_PATH / FileBrowser / monitoring use.
if err := agent.AssignDisk(ctx, uuid, where, fstype, ""); err != nil {
return storageInitResult{}, fmt.Errorf("csatlakoztatás sikertelen: %w", err)
return storageInitResult{}, util.MsgError("err.web.csatlakoztatas_sikertelen", err)
}
s.attachIntoGuest(ctx, agent, where)
// 5. Register the stable path — THE LAST step (marker-last, F6/Scenario B): a crash before this
@@ -191,10 +191,10 @@ func (s *Server) runStorageAttach(ctx context.Context, agent diskAgent, device,
// not in /disks — resolved via the raw-device scan's durable_id).
uuid := resolveEnrollUUID(ctx, agent, device)
if uuid == "" {
return storageInitResult{}, fmt.Errorf("a kiválasztott meghajtóhoz nem található fájlrendszer-azonosító (csak fájlrendszerrel rendelkező meghajtó csatolható)")
return storageInitResult{}, util.MsgError("err.web.a_kivalasztott_meghajtohoz_nem_talalhato_fajlrendszer")
}
if err := agent.AssignDisk(ctx, uuid, where, fstype, ""); err != nil {
return storageInitResult{}, fmt.Errorf("csatlakoztatás sikertelen: %w", err)
return storageInitResult{}, util.MsgError("err.web.csatlakoztatas_sikertelen", err)
}
s.attachIntoGuest(ctx, agent, where)
stable := stablePathForName(path.Base(where))
@@ -232,7 +232,7 @@ func (s *Server) awaitAgentFormat(ctx context.Context, agent diskAgent, device s
if err != nil {
consecutiveErrs++
if consecutiveErrs >= 5 {
return agentapi.FormatResult{}, fmt.Errorf("a formázás állapota nem kérdezhető le: %w", err)
return agentapi.FormatResult{}, util.MsgError("err.web.a_formazas_allapota_nem_kerdezheto_le", err)
}
} else {
consecutiveErrs = 0
@@ -240,9 +240,9 @@ func (s *Server) awaitAgentFormat(ctx context.Context, agent diskAgent, device s
case "done": // the agent's format-job terminal phases (internal/localapi/formatjob.go)
return agentapi.FormatResult{Device: device, Formatted: true}, nil
case "failed":
return agentapi.FormatResult{}, fmt.Errorf("formázás sikertelen: %s", st.Error)
return agentapi.FormatResult{}, util.MsgError("err.web.formazas_sikertelen_2", st.Error)
case "idle":
return agentapi.FormatResult{}, fmt.Errorf("a formázás nem indult el az eszközön (%s)", device)
return agentapi.FormatResult{}, util.MsgError("err.web.a_formazas_nem_indult_el_az", device)
// "running" (or an unexpected phase) → keep polling
}
}
@@ -261,10 +261,10 @@ func (s *Server) reEnrollClearMarker(where string) (bool, error) {
return false, nil
}
if err := s.settings.ClearDecommissioned(where); err != nil {
return false, fmt.Errorf("leszerelés visszavonása sikertelen: %w", err)
return false, util.MsgError("err.web.leszereles_visszavonasa_sikertelen", err)
}
if err := s.settings.SetSchedulable(where, true); err != nil {
return false, fmt.Errorf("ütemezhetőség visszaállítása sikertelen: %w", err)
return false, util.MsgError("err.web.utemezhetoseg_visszaallitasa_sikertelen", err)
}
s.logger.Printf("[INFO] [web] re-enrolled decommissioned drive — marker cleared: %s", where)
return true, nil
@@ -301,7 +301,7 @@ func (s *Server) registerStoragePath(where, label string, setDefault bool) error
AddedAt: time.Now().UTC().Format(time.RFC3339),
}
if err := s.settings.AddStoragePath(sp); err != nil {
return fmt.Errorf("regisztráció sikertelen: %w", err)
return util.MsgError("err.web.regisztracio_sikertelen", err)
}
go s.SyncFileBrowserMounts()
return nil
@@ -428,7 +428,7 @@ func (s *Server) handleStorageMigrate(w http.ResponseWriter, r *http.Request) {
}
id, err := s.stackMgr.MigrateAll(r.Context(), strings.TrimSpace(req.Source), strings.TrimSpace(req.Target))
if err != nil {
writeDiskJSON(w, http.StatusConflict, false, err.Error(), nil)
writeDiskJSON(w, http.StatusConflict, false, s.errText(r, err), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"started": true, "id": id})
@@ -453,7 +453,7 @@ func (s *Server) handleStorageMigrateApp(w http.ResponseWriter, r *http.Request)
}
id, err := s.stackMgr.MigrateApp(r.Context(), strings.TrimSpace(req.App), strings.TrimSpace(req.Target))
if err != nil {
writeDiskJSON(w, http.StatusConflict, false, err.Error(), nil)
writeDiskJSON(w, http.StatusConflict, false, s.errText(r, err), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"started": true, "id": id})
@@ -507,7 +507,7 @@ func (s *Server) handleStorageDecommission(w http.ResponseWriter, r *http.Reques
// source once every app has moved and come up on the target. A VALIDATE refusal returns here.
id, err := s.stackMgr.MigrateAllAndDecommission(r.Context(), req.Where, strings.TrimSpace(req.Target))
if err != nil {
writeDiskJSON(w, http.StatusConflict, false, err.Error(), nil)
writeDiskJSON(w, http.StatusConflict, false, s.errText(r, err), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"started": true, "id": id, "mode": "migrate"})
@@ -539,7 +539,7 @@ func (s *Server) handleStorageDecommission(w http.ResponseWriter, r *http.Reques
if errors.Is(err, errLastUsableDrive) {
status = http.StatusConflict
}
writeDiskJSON(w, status, false, err.Error(), nil)
writeDiskJSON(w, status, false, s.errText(r, err), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"decommissioned": true, "where": req.Where, "stopped_apps": stopped})
@@ -552,7 +552,7 @@ func (s *Server) handleStorageDecommission(w http.ResponseWriter, r *http.Reques
// errLastUsableDrive is the M1 refusal (never leave zero default) — a POLICY verdict, not a
// gateway failure. The decommission handler maps it to 409 so the JSON refusal reaches the
// browser intact (a 502 would be swallowed by the Cloudflare edge error page).
var errLastUsableDrive = errors.New("ez az egyetlen használható tárhely — a leszerelés megtagadva (előbb adj hozzá vagy állíts be másik alapértelmezett meghajtót)")
var errLastUsableDrive = util.MsgError("err.web.ez_az_egyetlen_hasznalhato_tarhely_a")
// finalizeDecommission resolves the agent client then soft-marks + decommissions (see *With).
func (s *Server) finalizeDecommission(ctx context.Context, where, migratedTo string) error {
@@ -576,7 +576,7 @@ func (s *Server) finalizeDecommissionWith(ctx context.Context, agent diskAgent,
return errLastUsableDrive
}
if err := s.settings.SetDecommissioned(where, migratedTo); err != nil {
return fmt.Errorf("nyilvántartás frissítése sikertelen: %w", err)
return util.MsgError("err.web.nyilvantartas_frissitese_sikertelen", err)
}
if promote != "" {
if derr := s.settings.SetDefaultStoragePath(promote); derr != nil {
@@ -587,7 +587,7 @@ func (s *Server) finalizeDecommissionWith(ctx context.Context, agent diskAgent,
}
// Registered path is the STABLE /mnt/felhom-drives/<name>; the agent decommissions the raw mount.
if _, err := agent.Decommission(ctx, agentWhere(where)); err != nil {
return fmt.Errorf("a meghajtó leszerelése sikertelen: %w", err)
return util.MsgError("err.web.a_meghajto_leszerelese_sikertelen", err)
}
if s.stackMgr != nil {
go s.SyncFileBrowserMounts()
@@ -629,7 +629,7 @@ func (s *Server) handleStorageInit(w http.ResponseWriter, r *http.Request) {
}
where, err := mountWhere(req.MountName)
if err != nil {
writeDiskJSON(w, http.StatusBadRequest, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadRequest, false, s.errText(r, err), nil)
return
}
if req.Device == "" {
@@ -638,7 +638,7 @@ func (s *Server) handleStorageInit(w http.ResponseWriter, r *http.Request) {
}
agent, err := s.agentClient()
if err != nil {
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
// F6: run format→mount→register as a DETACHED job (off the request context) the wizard polls via
@@ -760,7 +760,7 @@ func (s *Server) handleStorageWipe(w http.ResponseWriter, r *http.Request) {
}
agent, err := s.agentClient()
if err != nil {
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
// 1. Unmount (benign — frees the device so mkfs can run) + deregister the StoragePath. req.Where is
@@ -783,7 +783,7 @@ func (s *Server) handleStorageWipe(w http.ResponseWriter, r *http.Request) {
}
if !errors.Is(perr, agentapi.ErrNeedsConfirmation) {
if perr != nil {
writeDiskJSON(w, http.StatusBadGateway, false, s.msg(r, "disk.err.wipe_failed", perr.Error()), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.msg(r, "disk.err.wipe_failed", s.errText(r, perr)), nil)
return
}
// Already blank (no confirmation needed) — the format the agent just ran is the wipe.
@@ -792,7 +792,7 @@ func (s *Server) handleStorageWipe(w http.ResponseWriter, r *http.Request) {
}
fr, ferr := agent.FormatDisk(r.Context(), req.Device, fstype, true, probe.DurableID)
if ferr != nil {
writeDiskJSON(w, http.StatusBadGateway, false, s.msg(r, "disk.err.wipe_failed", ferr.Error()), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.msg(r, "disk.err.wipe_failed", s.errText(r, ferr)), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"device": req.Device, "wiped": fr.Formatted, "durable_id": fr.DurableID})
@@ -808,7 +808,7 @@ func (s *Server) handleStorageWipe(w http.ResponseWriter, r *http.Request) {
func (s *Server) HandleServerReboot(w http.ResponseWriter, r *http.Request) {
agent, err := s.agentClient()
if err != nil {
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
s.serverReboot(w, r, agent)
@@ -819,7 +819,7 @@ func (s *Server) HandleServerReboot(w http.ResponseWriter, r *http.Request) {
func (s *Server) serverReboot(w http.ResponseWriter, r *http.Request, agent diskAgent) {
if err := agent.GuestReboot(r.Context()); err != nil {
s.logger.Printf("[ERROR] [web] server reboot (guest restart) failed: %v", err)
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
s.logger.Printf("[WARN] [web] full server (guest) restart requested by operator")
@@ -855,7 +855,7 @@ func (s *Server) handleStorageRegister(w http.ResponseWriter, r *http.Request) {
stable := stablePathForName(path.Base(req.Where))
if err := s.registerStoragePath(stable, req.Label, req.SetDefault); err != nil {
s.logger.Printf("[WARN] [web] storage register %s (stable %s) failed: %v", req.Where, stable, err)
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
s.logger.Printf("[INFO] [web] storage path registered (existing mount): %s → %s", req.Where, stable)
@@ -908,7 +908,7 @@ func (s *Server) handleStorageRegisterMounted(w http.ResponseWriter, r *http.Req
}
if err := s.registerStoragePath(match.Path, req.Label, req.SetDefault); err != nil {
s.logger.Printf("[WARN] [web] mounted-store register %s failed: %v", match.Path, err)
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
s.logger.Printf("[INFO] [web] storage path registered (already-mounted store): %s", match.Path)
@@ -923,7 +923,7 @@ func (s *Server) handleStorageAttach(w http.ResponseWriter, r *http.Request) {
}
where, err := mountWhere(req.MountName)
if err != nil {
writeDiskJSON(w, http.StatusBadRequest, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadRequest, false, s.errText(r, err), nil)
return
}
if req.Device == "" {
@@ -932,12 +932,12 @@ func (s *Server) handleStorageAttach(w http.ResponseWriter, r *http.Request) {
}
agent, err := s.agentClient()
if err != nil {
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
res, err := s.runStorageAttach(r.Context(), agent, req.Device, req.FSType, where, req.Label, req.SetDefault)
if err != nil {
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
writeDiskJSON(w, http.StatusOK, true, "", res)
@@ -963,13 +963,13 @@ func (s *Server) handleStorageEject(w http.ResponseWriter, r *http.Request) {
}
agent, err := s.agentClient()
if err != nil {
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
// The registered path is the STABLE /mnt/felhom-drives/<name>; the agent operates on the raw mount.
res, err := agent.EjectDisk(r.Context(), agentWhere(req.Where))
if err != nil {
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
// Deregister the path (best-effort — the unmount already succeeded).