Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): route CLI_MISMATCH through the JS classifier, not a python USER_ERROR

[._.]/ Adam Eivyccfa55b40c0f
diff --git a/scripts/train_mflux_lora.py b/scripts/train_mflux_lora.py
index c4867d70ec..310f267b15 100644
--- a/scripts/train_mflux_lora.py
+++ b/scripts/train_mflux_lora.py
@@ -117,14 +117,15 @@ FATAL_PATTERNS = [
("OOM", re.compile(r"out of memory|Insufficient Memory|Metal.*out of memory|std::bad_alloc", re.I)),
("MODULE_NOT_FOUND", re.compile(r"ModuleNotFoundError|No module named", re.I)),
("HF_AUTH", re.compile(r"GatedRepoError|401 Client Error|is restricted|Repo.*is gated", re.I)),
- # argparse rejecting our flags / model choice means the installed mflux is
- # too old for FLUX.2 LoRA training (e.g. 0.12.x wants `--train-config` and
- # has no flux2 base models) — the exact failure that surfaced as a bare
- # "exited with code 2". CLI_MISMATCH mirrors failure.js.
- ("CLI_MISMATCH", re.compile(
- r"unrecognized arguments|invalid choice|the following arguments are required|"
- r"mflux-train: error", re.I)),
]
+# NOTE: argparse rejections (a too-old mflux that wants `--train-config` / has
+# no flux2 base models — the exact "exited with code 2" failure) are
+# deliberately NOT sniffed here. A USER_ERROR line short-circuits
+# classifyTrainingFailure on its *raw* text (failure.js), so sniffing the
+# argparse line would surface "unrecognized arguments: --config …" instead of
+# the actionable "upgrade mflux>=0.17" hint. Left unsniffed, the line rides the
+# non-zero-exit tail replay to stderr and failure.js's CLI_MISMATCH_RE renders
+# the actionable message — one source of truth for that text, on the JS side.
def resolve_mflux_output(configured: Path) -> Path:
diff --git a/server/services/loraTraining/failure.js b/server/services/loraTraining/failure.js
index afd977d4b5..f6617fa1b5 100644
--- a/server/services/loraTraining/failure.js
+++ b/server/services/loraTraining/failure.js
@@ -10,6 +10,10 @@ const HF_AUTH_RE = /GatedRepoError|401 Client Error|Repo.*is gated|Access to mod
// argparse rejecting the trainer's flags / model choice → the installed mflux
// predates FLUX.2 LoRA training (0.12.x wants `--train-config`, has no flux2
// base models). This is the failure that surfaced as a bare "exited with code 2".
+// The wrapper deliberately does NOT emit a USER_ERROR for this (which would
+// short-circuit below on the raw argparse text); the raw line rides the
+// trainer's stderr tail-replay here so this is the single source of the
+// actionable upgrade message. See train_mflux_lora.py FATAL_PATTERNS.
const CLI_MISMATCH_RE = /unrecognized arguments|invalid choice|the following arguments are required|mflux-train: error/i;
export function classifyTrainingFailure({ stderrTail = [], exitCode = null, signal = null, userError = null } = {}) {
diff --git a/server/services/loraTraining/failure.test.js b/server/services/loraTraining/failure.test.js
index a43a115873..0bdaf304e6 100644
--- a/server/services/loraTraining/failure.test.js
+++ b/server/services/loraTraining/failure.test.js
@@ -24,6 +24,10 @@ describe('classifyTrainingFailure', () => {
it('classifies argparse CLI mismatch as a stale-mflux upgrade hint', () => {
// The exact tail the wrapper replays when mflux 0.12.x rejects --config.
+ // This is the REAL production path: the wrapper intentionally does NOT emit
+ // a USER_ERROR for argparse rejections (that would short-circuit on the raw
+ // line), so CLI_MISMATCH must be reachable from stderrTail alone — with no
+ // userError set — for the actionable upgrade message to actually surface.
const tail = [
'mflux: usage: mflux-train [-h] ...',
'mflux: mflux-train: error: unrecognized arguments: --config /run/mflux-train.json',