{"record":{"id":"f3bbdb01064d86d0","repo":"kovidgoyal/kitty","slug":"kitty-public-key-environment-variable-does-not-hav","errorCode":null,"errorMessage":"KITTY_PUBLIC_KEY environment variable does not have a : in it","messagePattern":"KITTY_PUBLIC_KEY environment variable does not have a : in it","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cmd/at/main.go","lineNumber":83,"sourceCode":"func set_payload_string_field(io_data *rc_io_data, field, data string) {\n\tpayload_interface := reflect.ValueOf(&io_data.rc.Payload).Elem()\n\tstruct_in_interface := reflect.New(payload_interface.Elem().Type()).Elem()\n\tstruct_in_interface.Set(payload_interface.Elem()) // copies the payload to struct_in_interface\n\tstruct_in_interface.FieldByName(field).SetString(data)\n\tpayload_interface.Set(struct_in_interface) // copies struct_in_interface back to payload\n}\n\nfunc get_pubkey(encoded_key string) (encryption_version string, pubkey []byte, err error) {\n\tif encoded_key == \"\" {\n\t\tencoded_key = os.Getenv(\"KITTY_PUBLIC_KEY\")\n\t\tif encoded_key == \"\" {\n\t\t\terr = fmt.Errorf(\"Password usage requested but KITTY_PUBLIC_KEY environment variable is not available\")\n\t\t\treturn\n\t\t}\n\t}\n\tencryption_version, encoded_key, found := strings.Cut(encoded_key, \":\")\n\tif !found {\n\t\terr = fmt.Errorf(\"KITTY_PUBLIC_KEY environment variable does not have a : in it\")\n\t\treturn\n\t}\n\tif encryption_version != kitty.RC_ENCRYPTION_PROTOCOL_VERSION {\n\t\terr = fmt.Errorf(\"KITTY_PUBLIC_KEY has unknown version, if you are running on a remote system, update kitty on this system\")\n\t\treturn\n\t}\n\tpubkey = make([]byte, base85.DecodedLen(len(encoded_key)))\n\tn, err := base85.Decode(pubkey, []byte(encoded_key))\n\tif err == nil {\n\t\tpubkey = pubkey[:n]\n\t}\n\treturn\n}\n\ntype escaped_string string\n\nfunc (s escaped_string) MarshalJSON() ([]byte, error) {\n\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cmd/at/main.go#L65-L101","documentation":"KITTY_PUBLIC_KEY was found but is malformed: it must be of the form '<version>:<base85 key>' and contains no ':'. kitty @ cannot parse the encryption public key needed to password-protect remote control commands.","triggerScenarios":"get_pubkey does strings.Cut(encoded_key, \":\"); any manually set or mangled KITTY_PUBLIC_KEY lacking a colon (someone exported a bare key or truncated the value) triggers this.","commonSituations":"Users manually copying only part of the variable when forwarding it over ssh, shell quoting/escaping mistakes that strip the version prefix, or a stale/foreign value left in the environment.","solutions":["Unset the broken value and let kitty export the real variable: unset KITTY_PUBLIC_KEY, then run inside kitty","When forwarding manually, copy the entire '1:KEY...' string verbatim including the version prefix","Check shell quoting when exporting (avoid word-splitting or history expansion mangling it)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"v := os.Getenv(\"KITTY_PUBLIC_KEY\")\nif _, _, ok := strings.Cut(v, \":\"); !ok { /* bad env value; unset and re-export */ }","typeGuard":"func wellFormedPubKey(v string) bool { _, _, ok := strings.Cut(v, \":\"); return ok }","tryCatchPattern":null,"preventionTips":["Copy the whole version:key string when forwarding","Avoid manual re-typing of the variable"],"tags":["kitty","remote-control","environment-variable","parsing"],"backgroundTag":"malformed-env-var","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}