{"record":{"id":"9d163b0f82b2a907","repo":"chenhg5/cc-connect","slug":"corp-id-mismatch-expected-s-got-s","errorCode":null,"errorMessage":"corp_id mismatch: expected %s, got %s","messagePattern":"corp_id mismatch: expected (.+?), got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":784,"sourceCode":"\tplain := make([]byte, len(cipherData))\n\tmode.CryptBlocks(plain, cipherData)\n\n\tplain = pkcs7Unpad(plain)\n\n\tif len(plain) < 20 {\n\t\treturn \"\", fmt.Errorf(\"decrypted data too short\")\n\t}\n\n\tmsgLen := int(binary.BigEndian.Uint32(plain[16:20]))\n\tif 20+msgLen > len(plain) {\n\t\treturn \"\", fmt.Errorf(\"invalid message length %d in decrypted data (total %d)\", msgLen, len(plain))\n\t}\n\n\tmsg := string(plain[20 : 20+msgLen])\n\tcorpID := string(plain[20+msgLen:])\n\n\tif corpID != p.corpID {\n\t\treturn \"\", fmt.Errorf(\"corp_id mismatch: expected %s, got %s\", p.corpID, corpID)\n\t}\n\n\treturn msg, nil\n}\n\nfunc pkcs7Unpad(data []byte) []byte {\n\tif len(data) == 0 {\n\t\treturn data\n\t}\n\tpad := int(data[len(data)-1])\n\tif pad < 1 || pad > 32 || pad > len(data) {\n\t\treturn data\n\t}\n\treturn data[:len(data)-pad]\n}\n\n// downloadMedia fetches a temporary media file from WeChat Work by media_id.\nfunc (p *Platform) resolveUserName(userID string) string {","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L766-L802","documentation":"Trailing-field check at the end of decrypt: the corp_id appended after the message body in WeCom's plaintext layout does not equal this platform's configured corp_id. Decryption otherwise succeeded, which pinpoints the cause as a credential mix-up — the callback was encrypted for a different corp/app than the one configured here.","triggerScenarios":"Thrown at platform/wecom/wecom.go:784 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm corp_id, EncodingAESKey and token in config.toml all come from the same WeCom app","If multiple corps route to one endpoint, split them into separate platform instances","Reject the mismatched callback; it was never meant for this deployment"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}