{"record":{"id":"65e89f1043949f61","repo":"sipeed/picoclaw","slug":"ciphertext-length-d-is-not-a-multiple-of-block-si","errorCode":null,"errorMessage":"ciphertext length %d is not a multiple of block size","messagePattern":"ciphertext length (.+?) is not a multiple of block size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/wecom/media.go","lineNumber":109,"sourceCode":"\tif err == nil && len(key) == 32 {\n\t\treturn key, nil\n\t}\n\tkey, err = base64.StdEncoding.DecodeString(value + \"=\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decode AES key: %w\", err)\n\t}\n\tif len(key) != 32 {\n\t\treturn nil, fmt.Errorf(\"invalid AES key length %d\", len(key))\n\t}\n\treturn key, nil\n}\n\nfunc decryptAESCBC(key, ciphertext []byte) ([]byte, error) {\n\tif len(ciphertext) == 0 {\n\t\treturn nil, fmt.Errorf(\"ciphertext is empty\")\n\t}\n\tif len(ciphertext)%aes.BlockSize != 0 {\n\t\treturn nil, fmt.Errorf(\"ciphertext length %d is not a multiple of block size\", len(ciphertext))\n\t}\n\tblock, err := aes.NewCipher(key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create cipher: %w\", err)\n\t}\n\tplaintext := make([]byte, len(ciphertext))\n\tiv := key[:aes.BlockSize]\n\tcipher.NewCBCDecrypter(block, iv).CryptBlocks(plaintext, ciphertext)\n\treturn pkcs7Unpad(plaintext)\n}\n\nfunc pkcs7Unpad(data []byte) ([]byte, error) {\n\tif len(data) == 0 {\n\t\treturn nil, fmt.Errorf(\"empty plaintext\")\n\t}\n\tpadding := int(data[len(data)-1])\n\tif padding == 0 || padding > 32 || padding > len(data) {\n\t\treturn nil, fmt.Errorf(\"invalid padding size %d\", padding)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/wecom/media.go#L91-L127","documentation":"Error \"ciphertext length %d is not a multiple of block size\" thrown in sipeed/picoclaw.","triggerScenarios":"Thrown at pkg/channels/wecom/media.go:109 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}