{"record":{"id":"cbe60924b26676df","repo":"larksuite/cli","slug":"value-is-not-valid-json-w","errorCode":null,"errorMessage":"value is not valid JSON: %w","messagePattern":"value is not valid JSON: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":213,"sourceCode":"\t\t\tif !found {\n\t\t\t\tcombined = object\n\t\t\t\tfound = true\n\t\t\t} else if object.AdditionalProperties {\n\t\t\t\tcombined.AdditionalProperties = true\n\t\t\t}\n\t\t}\n\t\treturn combined, found\n\t}\n\treturn typedObjectShape{}, false\n}\nfunc valueCompatibleWithShape(value any, shape typedValueShape) error {\n\tencoded, err := json.Marshal(value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"value is not JSON-encodable: %w\", err)\n\t}\n\tnormalized, err := decodeJSONValidationValue(encoded)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"value is not valid JSON: %w\", err)\n\t}\n\treturn validateJSONValueAgainstShape(normalized, shape, \"value\")\n}\n","sourceCodeStart":195,"sourceCodeEnd":217,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L195-L217","documentation":"After successfully JSON-encoding the value, valueCompatibleWithShape decodes it via decodeJSONValidationValue to get a normalized JSON document for shape validation; if that decode fails, the value (or its marshaled form) is not valid JSON for validation purposes and this wrapped error is returned.","triggerScenarios":"An override Value whose json.Marshal output is rejected by decodeJSONValidationValue — e.g. a MarshalJSON emitting malformed JSON text, or emitting types the decoder refuses (invalid UTF-8, NaN/Inf smuggled through custom marshaling).","commonSituations":"Hand-rolled MarshalJSON returning invalid JSON strings; custom marshalers emitting NaN/Infinity for float fields; corrupted values produced by third-party types with buggy marshalers.","solutions":["Fix the custom MarshalJSON so it emits well-formed JSON (use json.Marshal on a plain representation inside it).","Replace NaN/Inf values with nil or a sentinel JSON value before validation.","Inspect the wrapped %w cause to find the exact decode failure, then correct the offending value."],"exampleFix":"// before\nfunc (v Value) MarshalJSON() ([]byte, byte) { return []byte(v.Raw), nil } // Raw may be invalid\n// after\nfunc (v Value) MarshalJSON() ([]byte, error) { return json.Marshal(v.Raw) }","handlingStrategy":"validation","validationCode":"func validMarshalOutput(v json.Marshaler) error {\n  b, err := v.MarshalJSON()\n  if err != nil { return err }\n  var out any\n  return json.Unmarshal(b, &out)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer embedding a plain struct and delegating to json.Marshal inside custom marshalers","Reject NaN/Inf at value construction time","Round-trip test every custom MarshalJSON: marshal then unmarshal"],"tags":["json","encoding","validation","shortcuts"],"backgroundTag":"invalid-json-value","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"}