{"record":{"id":"225e01b51362ddbc","repo":"larksuite/cli","slug":"svalue-does-not-match-any-of-oneof-alternatives","errorCode":null,"errorMessage":"%svalue does not match any of oneOf alternatives","messagePattern":"(.+?)value does not match any of oneOf alternatives","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_schema_validate.go","lineNumber":421,"sourceCode":"\t\t\tif hint := suggestEnumForError(value, schema.Enum); hint != \"\" {\n\t\t\t\tmsg += fmt.Sprintf(` (did you mean %q?)`, hint)\n\t\t\t}\n\t\t\tc.add(fmt.Errorf(\"%s\", msg)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t}\n\n\tif len(schema.OneOf) > 0 {\n\t\tmatched := false\n\t\tfor _, sub := range schema.OneOf {\n\t\t\tprobe := &schemaErrorCollector{}\n\t\t\tcollectSchemaErrors(value, sub, path, probe)\n\t\t\tif len(probe.errs) == 0 {\n\t\t\t\tmatched = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !matched {\n\t\t\tc.add(fmt.Errorf(\"%svalue does not match any of oneOf alternatives\", pathPrefix(path))) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t}\n\n\t// Object-level checks. `required` and `properties` are independent\n\t// per JSON Schema: `required` enforces keys regardless of whether\n\t// the schema also describes their per-key shape via `properties`.\n\tif obj, ok := value.(map[string]interface{}); ok {\n\t\tfor _, key := range schema.Required {\n\t\t\tif c.full() {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif _, present := obj[key]; !present {\n\t\t\t\tmsg := fmt.Sprintf(\"required property %q is missing at %s\", key, pathOrRoot(path))\n\t\t\t\t// Inline the missing field's type / one-line description / enum so\n\t\t\t\t// the agent supplies a correctly-shaped value on the first retry\n\t\t\t\t// instead of fetching the full schema.\n\t\t\t\tif hint := schemaFieldHint(schema.Properties[key]); hint != \"\" {\n\t\t\t\t\tmsg += \"; expected \" + hint","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_schema_validate.go#L403-L439","documentation":"oneOf validation error from collectSchemaErrors: the value matched none of the schema's `oneOf` alternatives. The validator probes each alternative and only reports this when every probe produced errors, so the actual per-alternative failures are suppressed in favor of a single aggregate message. Wrapped into a typed flag validation error with a --print-schema hint.","triggerScenarios":"Passing a value whose shape matches no oneOf branch, e.g. a polymorphic cell/row payload that is neither the `{cell:{...}}` form nor the `{value:{...}}` form defined by the schema.","commonSituations":"Mixing fields from two different alternatives into one object; missing a required discriminator key; passing a scalar where all alternatives expect an object.","solutions":["Run --print-schema and pick exactly one oneOf alternative; supply all of its required fields and none of the other branch's fields.","Compare your payload against each alternative's required/properties set field by field.","If fields from multiple branches were merged, split the payload to conform to a single branch."],"exampleFix":"// before\n--data '{\"cell\": 1, \"value\": \"x\"}'  // mixes two alternatives\n// after\n--data '{\"cell\": {\"text\": \"x\"}}'  // single valid alternative","handlingStrategy":"validation","validationCode":"// ensure the payload matches exactly one oneOf branch\nfunction matchesBranch(obj, requiredKeys) {\n  return requiredKeys.every(k => k in obj);\n}\nif (!matchesBranch(data, [\"cell\"]) && !matchesBranch(data, [\"value\"])) {\n  throw new Error(\"payload matches no oneOf alternative\");\n}","typeGuard":"function isCellPayload(v: unknown): v is { cell: object } {\n  return typeof v === \"object\" && v !== null && \"cell\" in v && Object.keys(v).every(k => [\"cell\"].includes(k));\n}","tryCatchPattern":"try {\n  runCommand(args);\n} catch (e) {\n  if (e.message.includes(\"oneOf\")) {\n    // fetch full schema via --print-schema and rebuild payload for one branch\n  }\n}","preventionTips":["Pick exactly one oneOf alternative; do not merge fields across branches.","Model each alternative as a distinct type in your code.","Validate the payload with a JSON-schema validator before calling."],"tags":["sheets","schema-validation","oneof"],"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"}