{"record":{"id":"aeed8d5d530da572","repo":"larksuite/cli","slug":"s-does-not-match-any-allowed-shape","errorCode":null,"errorMessage":"%s does not match any allowed shape","messagePattern":"(.+?) does not match any allowed shape","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":394,"sourceCode":"\t\treturn typedFieldValidation(field, \"cannot be represented as JSON: %v\", err).WithCause(err)\n\t}\n\tif err := validateJSONValueAgainstShape(jsonValue, field.shape, \"value\"); err != nil {\n\t\treturn typedFieldValidation(field, \"%v\", err).WithCause(err)\n\t}\n\treturn nil\n}\n\nfunc validateJSONValueAgainstShape(value any, shape typedValueShape, path string) error {\n\tswitch constraint := shape.(type) {\n\tcase anyJSONShape:\n\t\treturn nil\n\tcase typedOneOfShape:\n\t\tfor _, variant := range constraint.Variants {\n\t\t\tif err := validateJSONValueAgainstShape(value, variant, path); err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"%s does not match any allowed shape\", path)\n\tcase typedNullShape:\n\t\tif value != nil {\n\t\t\treturn fmt.Errorf(\"%s must be null\", path)\n\t\t}\n\t\treturn nil\n\tcase typedConstShape:\n\t\texpectedJSON, err := json.Marshal(constraint.Value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\texpected, err := decodeJSONValidationValue(expectedJSON)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\tif !reflect.DeepEqual(value, expected) {\n\t\t\treturn fmt.Errorf(\"%s must equal %v\", path, constraint.Value)\n\t\t}\n\t\treturn nil","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L376-L412","documentation":"A field declared with a oneOf shape constraint must match at least one of its declared variants; when the supplied JSON value matches none, the validator returns this error naming the failing path. It is thrown by validateJSONValueAgainstShape while checking values against compiled shape constraints.","triggerScenarios":"Supplying a value for a field whose schema is typedOneOfShape (e.g. string-or-object, or an enum of number ranges) that fails every variant — e.g. a plain string where variants require an object or a numeric id.","commonSituations":"Developers misread polymorphic API fields: sending {\"user\": \"abc\"} when the schema allows {\"user\": {\"id\": 12345}} or {\"user\": null}; or sending a list where only scalar/object variants are allowed.","solutions":["Inspect the schema (schema command / compiled constraint.Variants) and pick a value matching one listed variant exactly.","Fix the field's type/shape — e.g. wrap the scalar in the expected object.","If the schema is wrong (missing a legitimate variant), update the shape definition to include it."],"exampleFix":"// before\nparams.Set(\"owner\", \"team-x\") // oneOf: [object, null]\n\n// after\nparams.Set(\"owner\", map[string]any{\"id\": 12345})","handlingStrategy":"validation","validationCode":"// verify the value matches at least one oneOf variant before binding\nfor _, v := range variants {\n    if valueCompatibleWithShape(candidate, v, path) == nil { return true }\n}\nreturn false","typeGuard":null,"tryCatchPattern":"if err := binder.Set(\"owner\", val); err != nil {\n    if strings.Contains(err.Error(), \"does not match any allowed shape\") {\n        return fmt.Errorf(\"owner must be one of the documented shapes: %w\", err)\n    }\n    return err\n}","preventionTips":["Read the oneOf variants in the field's schema output before constructing values.","Test each accepted variant shape in dry-run mode.","Never assume a schema allows scalars where it lists objects."],"tags":["go","schema-validation","oneof","shape-constraint"],"backgroundTag":"schema-validation-failed","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"}