AlarmAckWriter: broad ArgumentException filter reports programming errors as auth/write failures #164
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
AlarmAckWriterclassifies interop failures withIsInteropFailure(src/ZB.MOM.WW.MxGateway.Worker/MxAccess/AlarmAckWriter.cs:252), which matchesExternalException,ArgumentExceptionandUnauthorizedAccessException. TheArgumentExceptionarm is needed because MXAccess's interop mapsE_INVALIDARGtoArgumentException. A wrong password or unknown user makesAuthenticateUserthrowArgumentException(0x80070057), as seen live on windev on 2026-10-19.Problem: the filter also catches programming-error
ArgumentExceptions (includingArgumentNullException) raised inside the same try blocks (:114AuthenticateUser,:182AddItem/Advise/Write). For example, a nullVerifyUserwould surface to the client asMXACCESS_FAILURE"Operator authentication failed … (HRESULT 0x80070057)" instead of an obvious bug.Suggested fix: narrow the filter to exceptions thrown by the COM call itself. Validate arguments before the try block so our own
ArgumentExceptions can't reach the catch. Alternatively, matchArgumentExceptiononly when it carriesHResult == E_INVALIDARGand is not anArgumentNullException/ArgumentOutOfRangeException. At minimum, add a comment explaining why the broad filter is deliberate.Found in the final review of PR #162 (feat/ackmsg-as-operator); left unfixed by decision as Minor.
https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT
Fixed on feat/ackmsg-as-operator (PR #162) in
219611c+463748e. Each MXAccess call (AuthenticateUser, AddItem, Advise, Write) now runs in its own narrow interop filter that wraps the failure in a private AckInteropException; the outer catches catch only that. Argument checks, caching and the pump step now propagate as bugs. (A first attempt filtered on HResult == E_INVALIDARG, but a managed ArgumentException already defaults to 0x80070057, so that was dropped.) windev Worker.Tests 585/0. Closes when PR #162 merges.https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT