在调用文字检查云函数时报错,之前一直能正常工作的,今天发现报错请问怎样解决?
云函数部分:
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
const { value, text } = event;
try {
let msgR = false;
let imageR = false;
//检查 文字内容是否违规
if (text) {
msgR = await cloud.openapi.security.msgSecCheck({
content: text
})
}
//检查 图片内容是否违规
if (value) {
imageR = await cloud.openapi.security.imgSecCheck({
media: {
header: { 'Content-Type': 'application/octet-stream' },
contentType: 'image/png',
value: Buffer.from(value)
}
})
}
return {
msgR, //内容检查返回值
imageR //图片检查返回值
};
} catch (err) {
// 错误处理
// err.errCode !== 0
return err
}
return {
event,
msgR,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}
出错信息:
WAServiceMainContext.js?t=wechat&s=1668601404620&v=2.25.0:1 call failed:, Error: cloud.callFunction:fail Error: errCode: -501001 resource system error | errMsg: RuleParseError: JSON5: invalid end of input at 1:1 (callId: 1668602024517-0.8778514413563852) (trace: 20:33:44 start->20:33:44 system error (Error: errCode: -501001 resource system error | errMsg: RuleParseError: JSON5: invalid end of input at 1:1), abort)