{"record":{"id":"d982a9470ca3da38","repo":"JeffreySu/WeiXinMPSDK","slug":"finance-sdk","errorCode":null,"errorMessage":"Finance SDK 返回的会话内容为空。","messagePattern":"Finance SDK 返回的会话内容为空。","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/MsgAudit/MsgAuditFinanceClient.cs","lineNumber":101,"sourceCode":"            {\n                throw new ArgumentOutOfRangeException(nameof(limit), \"单次拉取条数必须介于 1 和 1000 之间。\");\n            }\n\n            lock (_syncRoot)\n            {\n                ThrowIfDisposed();\n                var slice = _nativeApi.NewSlice();\n                EnsureNativeHandle(slice, \"NewSlice\");\n                try\n                {\n                    var errorCode = _nativeApi.GetChatData(_sdk, sequence, limit, _proxy,\n                        _proxyPassword, _timeoutSeconds, slice);\n                    ThrowIfNativeError(errorCode, \"GetChatData\");\n\n                    var json = _nativeApi.GetSliceContent(slice);\n                    if (string.IsNullOrWhiteSpace(json))\n                    {\n                        throw new InvalidDataException(\"Finance SDK 返回的会话内容为空。\");\n                    }\n\n                    var result = JsonSerializer.Deserialize(json,\n                        MsgAuditFinanceJsonSerializerContext.Default.MsgAuditFinanceChatDataResult);\n                    if (result == null)\n                    {\n                        throw new InvalidDataException(\"无法解析 Finance SDK 返回的会话内容 JSON。\");\n                    }\n\n                    result.raw_json = json;\n                    return result;\n                }\n                finally\n                {\n                    _nativeApi.FreeSlice(slice);\n                }\n            }\n        }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/MsgAudit/MsgAuditFinanceClient.cs#L83-L119","documentation":"After GetChatData calls the native Finance SDK and it reports success, the client reads the slice content. If the SDK returns null/empty JSON for the slice, it throws InvalidDataException because an empty payload cannot represent a valid chat-data result.","triggerScenarios":"Native SDK GetSliceContent returns empty for a slice — e.g. corrupted slice handle, SDK/environment mismatch, proxy/network interference truncating the response, or the slice being freed before read.","commonSituations":"Mismatched native SDK binary versions on the host; running on an OS/arch where the SDK misbehaves; expired/invalid chatdata causing the SDK to return nothing without a nonzero error code.","solutions":["Verify the WeWork Finance native SDK binary version matches the SDK the .NET wrapper targets and reinstall if needed","Check network/proxy settings in MsgAuditFinanceOptions (proxy/proxyPassword) and corporate firewall rules to qyapi.weixin.qq.com","Regenerate/retry the pull from the last known sequence; check the seq cursor is valid","Enable/inspect ThrowIfNativeError output — a zero code with empty content usually indicates an SDK-side issue to report upstream"],"exampleFix":"// before\nvar slice = client.NewSlice(...); // slice content empty -> exception\n// after\nvar result = client.GetChatData(seq, 1000);\nif (result == null || result.ChatData == null || result.ChatData.Count == 0)\n{\n    _logger.LogWarning(\"No chat data for seq {Seq}; will retry later\", seq);\n    return;\n}","handlingStrategy":"try-catch","validationCode":"// check SDK load and options before pulling\nif (!NativeSdkProbe.IsLoaded()) throw new InvalidOperationException(\"Finance SDK not loaded\");","typeGuard":null,"tryCatchPattern":"try { var data = client.GetChatData(seq, 1000); } catch (InvalidDataException ex) { log.Warn(ex, \"Empty finance slice at seq {Seq}\", seq); await Task.Delay(backoff); ScheduleRetry(seq); }","preventionTips":["Verify native SDK version matches the wrapper package","Validate proxy/network config for the host environment","Persist the last successful sequence for safe retries"],"tags":["native-sdk","empty-response","msgaudit","wecom"],"backgroundTag":"empty-response-body","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"}