{"record":{"id":"c9af8e91506a2b5f","repo":"larksuite/cli","slug":"expected-string-key-got-v","errorCode":null,"errorMessage":"expected string key, got %v","messagePattern":"expected string key, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/schema/types.go","lineNumber":167,"sourceCode":"func (o *OrderedProps) UnmarshalJSON(data []byte) error {\n\tdec := json.NewDecoder(bytes.NewReader(data))\n\ttok, err := dec.Token()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif delim, ok := tok.(json.Delim); !ok || delim != '{' {\n\t\treturn fmt.Errorf(\"expected object, got %v\", tok)\n\t}\n\to.Order = nil\n\to.Map = make(map[string]Property)\n\tfor dec.More() {\n\t\tkeyTok, err := dec.Token()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tkey, ok := keyTok.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected string key, got %v\", keyTok)\n\t\t}\n\t\tvar prop Property\n\t\tif err := dec.Decode(&prop); err != nil {\n\t\t\treturn err\n\t\t}\n\t\to.Order = append(o.Order, key)\n\t\to.Map[key] = prop\n\t}\n\tif _, err := dec.Token(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n","sourceCodeStart":149,"sourceCodeEnd":181,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/schema/types.go#L149-L181","documentation":"While iterating the object's key/value pairs in OrderedMap.UnmarshalJSON, each key token must be a JSON string. A non-string key token (only possible with malformed or exotic input) triggers this error, protecting the map[string]Property backing store.","triggerScenarios":"Decoding JSON where a key token decoded via dec.Token() is not a string. Standard JSON only permits string keys, so this typically fires on hand-crafted or corrupted input streams, or when the decoder position is misaligned (e.g. input mutated between tokens).","commonSituations":"Corrupted or truncated JSON streams; custom decoder pipelines that feed tokens out of order; fuzzed input to schema parsing.","solutions":["Validate the JSON payload parses cleanly with a standard decoder before consuming tokens","Verify input has not been truncated or corrupted in transit","Check that no other reader consumed tokens from the same decoder/stream beforehand"],"exampleFix":"// before\ntok, _ := dec.Token(); use(tok.(int))\n// after\nkeyTok, err := dec.Token()\nif err != nil { return err }\nif k, ok := keyTok.(string); !ok { return fmt.Errorf(\"expected string key, got %v\", keyTok) } else { _ = k }","handlingStrategy":"try-catch","validationCode":"var probe map[string]json.RawMessage\nif err := json.Unmarshal(data, &probe); err != nil {\n\treturn fmt.Errorf(\"payload is not a valid JSON object: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := json.Unmarshal(data, &om); err != nil {\n\tif strings.Contains(err.Error(), \"expected string key\") {\n\t\t// treat input as corrupted; re-fetch or use defaults\n\t}\n\treturn err\n}","preventionTips":["Sanity-check payloads with a standard decode before streaming tokens","Guard against truncated/corrupted transfer (checksums, length checks)","Don't share decoders/streams between readers"],"tags":["json","unmarshal","schema"],"backgroundTag":"json-type-mismatch","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}