{"record":{"id":"3fa751d677b47fea","repo":"JeffreySu/WeiXinMPSDK","slug":"sdk-0","errorCode":null,"errorMessage":"原生 SDK 网络请求超时时间必须大于 0 秒。","messagePattern":"原生 SDK 网络请求超时时间必须大于 0 秒。","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/MsgAudit/MsgAuditFinanceClient.cs","lineNumber":284,"sourceCode":"\n        private static IMsgAuditFinanceNativeApi CreateNativeApi(MsgAuditFinanceOptions options)\n        {\n            ValidateOptions(options);\n            return new MsgAuditFinanceNativeApi(options.LibraryPath);\n        }\n\n        private static void ValidateOptions(MsgAuditFinanceOptions options)\n        {\n            if (options == null)\n            {\n                throw new ArgumentNullException(nameof(options));\n            }\n\n            ValidateRequiredText(options.CorpId, nameof(options.CorpId));\n            ValidateRequiredText(options.Secret, nameof(options.Secret));\n            if (options.TimeoutSeconds <= 0)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options.TimeoutSeconds),\n                    \"原生 SDK 网络请求超时时间必须大于 0 秒。\");\n            }\n        }\n\n        private static void ValidateRequiredText(string value, string parameterName)\n        {\n            if (string.IsNullOrWhiteSpace(value))\n            {\n                throw new ArgumentException(\"参数不能为空。\", parameterName);\n            }\n        }\n\n        private static void EnsureNativeHandle(IntPtr handle, string operation)\n        {\n            if (handle == IntPtr.Zero)\n            {\n                throw new InvalidOperationException($\"Finance SDK 的 {operation} 操作返回了空指针。\");\n            }","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/MsgAudit/MsgAuditFinanceClient.cs#L266-L302","documentation":"ValidateOptions enforces that MsgAuditFinanceOptions.TimeoutSeconds is strictly positive because the value is passed to the native Finance SDK as its network request timeout. Zero or negative values are rejected with ArgumentOutOfRangeException.","triggerScenarios":"Constructing MsgAuditFinanceClient with options whose TimeoutSeconds is 0 or negative — typically from a default(T) struct, a misparsed config value, or an explicit 0 intended to mean 'no timeout'.","commonSituations":"App config or environment variable yielding 0 after int.Parse, a struct default initialized without setting TimeoutSeconds, or developers assuming 0 disables the timeout (it does not).","solutions":["Set TimeoutSeconds to a positive value in MsgAuditFinanceOptions (e.g. 30)","Check the config source that populates TimeoutSeconds and fix the parsing/defaulting","If relying on defaults, ensure the options object is initialized, not default(MsgAuditFinanceOptions)"],"exampleFix":"// before\nvar options = new MsgAuditFinanceOptions { CorpId = corpId, Secret = secret }; // TimeoutSeconds = 0\n// after\nvar options = new MsgAuditFinanceOptions { CorpId = corpId, Secret = secret, TimeoutSeconds = 30 };","handlingStrategy":"validation","validationCode":"if (options.TimeoutSeconds <= 0) throw new InvalidOperationException(\"TimeoutSeconds must be positive, e.g. 30\");","typeGuard":null,"tryCatchPattern":"try { var client = new MsgAuditFinanceClient(options); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"options.TimeoutSeconds\") { options.TimeoutSeconds = 30; /* retry */ }","preventionTips":["Give TimeoutSeconds a nonzero default in option classes/config binding","Clamp parsed config values: Math.Max(1, parsed)","Document that 0 does not mean 'infinite timeout' for this SDK"],"tags":["csharp","argument-out-of-range","timeout","configuration","weixin-work"],"backgroundTag":"argument-out-of-range","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}