{"record":{"id":"82d35182e7047009","repo":"kovidgoyal/kitty","slug":"could-not-guess-the-data-type-of-s-with-error","errorCode":null,"errorMessage":"could not guess the data type of: %s with error: %w","messagePattern":"could not guess the data type of: (.+?) with error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/desktop_ui/portal.go","lineNumber":243,"sourceCode":"\t}\n\treturn\n}\n\nfunc ParseValueWithSignature(value, value_type_signature string) (v dbus.Variant, err error) {\n\tvar s dbus.Signature\n\tif value_type_signature != \"\" {\n\t\tif value_type_signature[0] == '@' {\n\t\t\tvalue_type_signature = value_type_signature[1:]\n\t\t}\n\t\ts, err = dbus.ParseSignature(value_type_signature)\n\t\tif err != nil {\n\t\t\treturn dbus.Variant{}, fmt.Errorf(\"%s is not a valid type signature: %w\", value_type_signature, err)\n\t\t}\n\t}\n\tv, err = dbus.ParseVariant(value, s)\n\tif err != nil {\n\t\tif value_type_signature == \"\" {\n\t\t\treturn dbus.Variant{}, fmt.Errorf(\"could not guess the data type of: %s with error: %w\", value, err)\n\t\t}\n\t\treturn dbus.Variant{}, fmt.Errorf(\"%s is not a valid value for signature: %#v with error: %w\", value, value_type_signature, err)\n\t}\n\treturn v, nil\n}\n\nfunc ParseValue(value string) (dbus.Variant, error) {\n\treturn ParseValueWithSignature(value, \"\")\n}\n\ntype ShowSettingsOptions struct {\n\tAsJson             bool\n\tAllowOtherBackends bool\n\tInNamespace        []string\n}\n\nfunc fetch_settings(conn *dbus.Conn, namespaces ...string) (ans ReadAllType, err error) {\n\tpath := \"/\" + strings.ToLower(strings.ReplaceAll(DESKTOP_PORTAL_NAME, \".\", \"/\"))","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/desktop_ui/portal.go#L225-L261","documentation":"When no type signature is supplied, ParseValueWithSignature calls dbus.ParseVariant which must infer the variant type from the string alone. If the string is ambiguous or unparseable (e.g. empty string or malformed GVariant text), inference fails with this error.","triggerScenarios":"Calling set with a value that GVariant text format cannot auto-type, such as an empty string, bare punctuation, or nested structures without full syntax.","commonSituations":"Passing an empty value intending a deletion but hitting a code path that still parses; copy-pasting values with smart quotes or missing quotes around strings that need them.","solutions":["Supply an explicit type signature (e.g. @s, @u) so parsing need not guess","Quote string values properly per GVariant text format","For deletion, pass no value/empty value to the set command as documented"],"exampleFix":"# before\nkitten desktop-ui set ns key\n# after (explicit signature)\nkitten desktop-ui set ns key --value-type '@s' hello","handlingStrategy":"validation","validationCode":"if value == \"\" {\n    return errors.New(\"empty value: supply an explicit type signature\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := portal.ParseValue(v); err != nil {\n    if _, e2 := portal.ParseValueWithSignature(v, \"@s\"); e2 == nil {\n        // treat as string\n    }\n}","preventionTips":["Always pass an explicit signature when the value could be ambiguous","Quote strings per GVariant text format"],"tags":["dbus","gvariant","desktop-ui","type-inference"],"backgroundTag":"gvariant-type-inference-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}