{"record":{"id":"f521ec8836b6ab04","repo":"larksuite/cli","slug":"input-relations-d-kind-q-is-invalid","errorCode":null,"errorMessage":"Input.Relations[%d].Kind %q is invalid","messagePattern":"Input\\.Relations\\[(.+?)\\]\\.Kind %q is invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":24,"sourceCode":"\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc compileRelations(definitions []typedRelation, fieldByName map[string]int) ([]compiledRelation, error) {\n\tresult := make([]compiledRelation, 0, len(definitions))\n\tseen := make(map[string]struct{})\n\tfor i, definition := range definitions {\n\t\tminimum := 2\n\t\texact := 0\n\t\tswitch definition.Kind {\n\t\tcase typedRelationExactlyOne, typedRelationAtLeastOne, typedRelationCoOccur, typedRelationConflicts:\n\t\tcase typedRelationRequires:\n\t\t\texact = 2\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d].Kind %q is invalid\", i, definition.Kind)\n\t\t}\n\t\tif exact > 0 && len(definition.Params) != exact || exact == 0 && len(definition.Params) < minimum {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] kind %s has invalid param count %d\", i, definition.Kind, len(definition.Params))\n\t\t}\n\t\tif definition.Presence != typedPresenceExplicit && definition.Presence != typedPresenceNonZero {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d].Presence %q is invalid\", i, definition.Presence)\n\t\t}\n\t\tif definition.Stage != typedStageSourcePreRun && definition.Stage != typedStageAfterPrepare {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d].Stage %q is invalid\", i, definition.Stage)\n\t\t}\n\t\tcompiled := compiledRelation{kind: definition.Kind, presence: definition.Presence, stage: definition.Stage}\n\t\tlocal := make(map[string]struct{})\n\t\tfor _, name := range definition.Params {\n\t\t\tfield, ok := fieldByName[name]\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] references unknown param --%s\", i, name)\n\t\t\t}\n\t\t\tif _, duplicate := local[name]; duplicate {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L6-L42","documentation":"compileRelations validates each entry of Input.Relations against the known relation kinds: exactly_one, at_least_one, co_occur, conflicts (>=2 params) and requires (exactly 2 params). An unrecognized Kind string produces this compile-time error, preventing malformed relation declarations from reaching the runtime.","triggerScenarios":"Declaring a relation with a typo'd or invented Kind, e.g. Kind: \"exactlyone\" or \"mutually-exclusive\", in a typed input definition.","commonSituations":"Hand-writing relation kinds instead of using the typed constants (typedRelationExactlyOne, etc.); rebasing code across renamed kind values.","solutions":["Use the exported typed constants (typedRelationExactlyOne, typedRelationAtLeastOne, typedRelationCoOccur, typedRelationConflicts, typedRelationRequires) rather than raw strings","Fix the spelling of the Kind value to match one of the supported constants","Run the shortcut package's compile tests to catch this before startup"],"exampleFix":"// before\nRelations: []typedRelation{{Kind: \"exactlyone\", Params: []string{\"a\",\"b\"}}}\n// after\nRelations: []typedRelation{{Kind: typedRelationExactlyOne, Params: []string{\"a\",\"b\"}}}","handlingStrategy":"validation","validationCode":"func knownRelationKind(k typedRelationKind) bool {\n\tswitch k {\n\tcase typedRelationExactlyOne, typedRelationAtLeastOne,\n\t\ttypedRelationCoOccur, typedRelationConflicts, typedRelationRequires:\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":"func isTypedRelationKind(v any) bool {\n\tk, ok := v.(typedRelationKind)\n\treturn ok && knownRelationKind(k)\n}","tryCatchPattern":null,"preventionTips":["Always use the typedRelation* constants, never raw strings","Let the compiler catch typos by referencing constants","Keep a table-driven test compiling every relation kind"],"tags":["go","validation","compile-time","relations"],"backgroundTag":"invalid-enum-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"}