{"record":{"id":"a8b0b4d4892c2b0e","repo":"TheAlgorithms/Go","slug":"the-size-of-chars-must-be-even","errorCode":null,"errorMessage":"the size of \"chars\" must be even","messagePattern":"the size of \"chars\" must be even","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cipher/polybius/polybius.go","lineNumber":91,"sourceCode":"\t\tdecryptedText += decryptedChar\n\t}\n\treturn decryptedText, nil\n}\n\nfunc (p *Polybius) encipher(char rune) (string, error) {\n\tindex := strings.IndexRune(p.key, char)\n\tif index < 0 {\n\t\treturn \"\", fmt.Errorf(\"%q does not exist in keys\", char)\n\t}\n\trow := index / p.size\n\tcol := index % p.size\n\tchars := []rune(p.characters)\n\treturn string([]rune{chars[row], chars[col]}), nil\n}\n\nfunc (p *Polybius) decipher(chars []rune) (string, error) {\n\tif len(chars) != 2 {\n\t\treturn \"\", fmt.Errorf(\"the size of \\\"chars\\\" must be even\")\n\t}\n\trow := strings.IndexRune(p.characters, chars[0])\n\tif row < 0 {\n\t\treturn \"\", fmt.Errorf(\"%c does not exist in characters\", chars[0])\n\t}\n\tcol := strings.IndexRune(p.characters, chars[1])\n\tif col < 0 {\n\t\treturn \"\", fmt.Errorf(\"%c does not exist in characters\", chars[1])\n\t}\n\treturn string(p.key[row*p.size+col]), nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":103,"githubUrl":"https://github.com/TheAlgorithms/Go/blob/5ba447ec5ff3d1213de65b92e726ee74c5d5cc19/cipher/polybius/polybius.go#L73-L103","documentation":"decipher expects exactly two runes (a row char and a column char); being handed 0 or 1 runes means the ciphertext had odd length or the slicing window was wrong, so it reports the pair-size requirement.","triggerScenarios":"Thrown at cipher/polybius/polybius.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check len(text)%2==0 before decrypting and reject odd-length ciphertext","Ensure ciphertext was produced by this cipher (pairs of characters)","Handle the trailing leftover rune explicitly instead of calling decipher with one rune"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ba447ec5ff3d1213de65b92e726ee74c5d5cc19","analyzedAt":"2026-09-02T21:54:30.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}