问题类型
请在此选择你的问题类型:
关于问题或建议的简单描述
与问题或建议相关的源代码
对于报告缺陷,请在此粘贴与问题相关的代码,或提供可复现问题的最小化项目(可提供仓库地址或 GitHub Gist)。
对于请求新功能,请在此粘贴已有实现思路或解决方案。
注意,请不要以截图形式提供代码。
try
{
int ret = /* 获取聊天记录数据 */
IsRunOnWindows() ? FinanceDllWindowsPInvoker.GetChatData(_sdkPtr, request.LastSequence, request.Limit, _proxyAddress!, _proxyAuthentication!, (request.Timeout ?? _timeout) / 1000, dataPtr) :
IsRunOnLinux() ? FinanceDllLinuxPInvoker.GetChatData(_sdkPtr, request.LastSequence, request.Limit, _proxyAddress!, _proxyAuthentication!, (request.Timeout ?? _timeout) / 1000, dataPtr) :
throw new PlatformNotSupportedException();
if (ret == 0)
{
//int dataSize = /* 获取聊天记录数据内容长度 */
// IsRunOnWindows() ? FinanceDllWindowsPInvoker.GetSliceLen(dataPtr) :
// IsRunOnLinux() ? FinanceDllLinuxPInvoker.GetSliceLen(dataPtr) :
// throw new PlatformNotSupportedException();
IntPtr dataContentPtr = /* 获取聊天记录数据内容 */
IsRunOnWindows() ? FinanceDllWindowsPInvoker.GetContentFromSlice(dataPtr) :
IsRunOnLinux() ? FinanceDllLinuxPInvoker.GetContentFromSlice(dataPtr) :
throw new PlatformNotSupportedException();
string dataContent = MarshalerHelper.PtrToStringUTF8(dataContentPtr);
response = JsonSerializer.Deserialize<Models.GetChatRecordsResponse>(dataContent);
response.RawBytes = Encoding.UTF8.GetBytes(dataContent);
}
response.ReturnCode = ret;
return response;
}
catch (Exception ex)
{
throw new WechatWorkFinanceException("Failed to fetch chat data. Please see the inner exception for more details.", ex);
}
异常堆栈或异常原因
SKIT.FlurlHttpClient.Wechat.Work.WechatWorkFinanceException:
Failed to decrypt chat data. Please see the inner exception for more details.
---> System.Text.Json.JsonException: '0x14' is invalid within a JSON string. The string should be correctly escaped. Path: $.text.content | LineNumber: 0 | BytePositionInLine: 1143.
---> System.Text.Json.JsonReaderException: '0x14' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 1143.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan
1 data, Int32 idx)
at System.Text.Json.Utf8JsonReader.ConsumeString()
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter
1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter
1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter
1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan
1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan
1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at SKIT.FlurlHttpClient.Wechat.Work.SDK.Finance.WechatWorkFinanceClient.<>c__DisplayClass18_0.b__0()
--- End of inner exception stack trace ---
at SKIT.FlurlHttpClient.Wechat.Work.SDK.Finance.WechatWorkFinanceClient.<>c__DisplayClass18_0.b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at WechatWorkSystem.WechatWorkSdks.FinanceChatRecordProxy.DecryptChatRecordAsync(DecryptChatRecordRequest request, CancellationToken cancellationToken)
发生问题的运行环境
请在此填写以下几项内容:
补充说明
请在此填写任何其他可以定位问题或帮助说明的信息。
方便断点看一下 dataContent
此时的值是什么吗?
注:如有敏感信息请脱敏后再上传。
感谢大佬回复。为了让生产环境尽快恢复,我们已经跳过了特定的Sequence,研发也没有记录。 看后续是否可以捕获到类似异常。 我们一个月出现了两次相同的问题,这个频率还是有点高的
{
"msgid": "3178079165664247997_1704039311141_external",
"action": "send",
"from": "wmK6y0EQAAoNqzHUd6oFE3zMu1YUXsMg",
"tolist": [
"wmK6y0EQAAcb5cF7NBNhXA8hE4P4wS8g",
"wmK6y0EQAA3XL3klG67NqMFGCvAHokcw",
"wmK6y0EQAA9s5D5O0PKCS3u_KxVryM0Q",
"wmK6y0EQAAyf0ixJb8e2E1e-ssMj0NOQ",
"wmK6y0EQAAH9e4UW58lT35oDFZBFzkAg",
"wmK6y0EQAAseRDDAmvhsMGCTx3oPzJUQ",
"wmK6y0EQAAKe9XS5vFX-MGv3ej8hdX-Q",
"wmK6y0EQAAdzh8g0W0KuQ3FOL5yBX67A",
"wmK6y0EQAAKfX7lnwy6N0pM31flk47BA",
"wmK6y0EQAAwYimBSA7tMsUxtLk5nVrGg",
"wmK6y0EQAA73J8IshRPpBxZ0V4kU1BJg",
"wmK6y0EQAA94G3L2Sud-2WcJX9yQ8w_A",
"wmK6y0EQAAJoU77ZRx89bCRUoevVZyrw",
"wmK6y0EQAA1gJiIl8W7V_xkhBlsvC94A",
"wmK6y0EQAAgNY1vKGusLyiDF32LFnEEA",
"wmK6y0EQAAkYibPtx2O8I1L10lWQjEQQ",
"wmK6y0EQAAxYvwm628u6vb6TYsfDfx1g",
"wmK6y0EQAA8SAoldyLI4LZBcemu0K3bg",
"wmK6y0EQAAJ6LvS8D-7qHDFRlAvPi5lQ",
"wmK6y0EQAAfpfWferFaBDm9NnORQrh9g",
"wmK6y0EQAAC_U-nBkGettmasVnML5L-g",
"wmK6y0EQAAzv9He_b5ueu47yhgbh9kCw"
],
"roomid": "wrK6y0EQAAAbheL4qb3MqFAOU-Og8beA",
"msgtime": 1704039307488,
"msgtype": "text",
"text": {
"content": "新年快乐,2024全部上岸\u0014[烟花]"
}
}
\u0014导致转义失败
可尝试指定 JSON 序列化器为 Newtonsoft.Json。
默认的 System.Text.Json 对 JSON 格式的合法性要求比较严格。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
发布了 v2.25.0,尝试修复此问题,麻烦升级到此版本后再观察一下。
登录 后才可以发表评论