From 68eb9adae7b11a9c34eb85a1b943745eeca93508 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 3 May 2026 23:43:55 -0400 Subject: [PATCH] mxaccesscli: catch ArgumentException from AuthenticateUser as auth-failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under eOSUserBased galaxy security mode the LMXProxyServer raises ArgumentException("Value does not fall within the expected range") for bad credentials instead of silently returning 0 like permissive (eNone) galaxies do. Both shapes mean "auth failed"; MxSession.Authenticate now normalizes them into a 0 return so WriteCommand reports a clean "authentication-failed" envelope and exits 1 — instead of crashing with a stack trace. Verified live against the ZB galaxy in eOSUserBased mode: bad password -> ok=false, error="authentication-failed", exit 1 good password -> ok=true, auth_user_id=1, exit 0 Co-Authored-By: Claude Opus 4.7 (1M context) --- mxaccesscli/src/MxAccess.Cli/Mx/MxSession.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mxaccesscli/src/MxAccess.Cli/Mx/MxSession.cs b/mxaccesscli/src/MxAccess.Cli/Mx/MxSession.cs index 8452804..a4577a8 100644 --- a/mxaccesscli/src/MxAccess.Cli/Mx/MxSession.cs +++ b/mxaccesscli/src/MxAccess.Cli/Mx/MxSession.cs @@ -58,7 +58,19 @@ namespace MxAccess.Cli.Mx { if (string.IsNullOrEmpty(verifyUser)) throw new ArgumentException("verifyUser must be non-empty.", nameof(verifyUser)); - return _proxy.AuthenticateUser(_hServer, verifyUser, password ?? string.Empty); + // Some galaxy configurations (e.g. eOSUserBased) cause the proxy to + // throw `ArgumentException: Value does not fall within the expected + // range` for bad credentials instead of returning 0 like the + // permissive (eNone) configuration does. Both shapes mean "auth + // failed"; the caller distinguishes via a non-zero return value. + try + { + return _proxy.AuthenticateUser(_hServer, verifyUser, password ?? string.Empty); + } + catch (ArgumentException) + { + return 0; + } } /// Pump COM messages while watching for an update that matches the predicate.