{"record":{"id":"d5e54375e60cd053","repo":"larksuite/cli","slug":"input-relations-d-references-unknown-param-s","errorCode":null,"errorMessage":"Input.Relations[%d] references unknown param --%s","messagePattern":"Input\\.Relations\\[(.+?)\\] references unknown param --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":40,"sourceCode":"\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 {\n\t\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] repeats param --%s\", i, name)\n\t\t\t}\n\t\t\tlocal[name] = struct{}{}\n\t\t\tcompiled.fields = append(compiled.fields, field)\n\t\t}\n\t\tkeyBytes, _ := json.Marshal(definition)\n\t\tkey := string(keyBytes)\n\t\tif _, duplicate := seen[key]; duplicate {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] duplicates an earlier relation\", i)\n\t\t}\n\t\tseen[key] = struct{}{}\n\t\tresult = append(result, compiled)\n\t}\n\treturn result, nil\n}\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L22-L58","documentation":"This error is thrown at shortcut-definition compile time when a relation declared in Input.Relations lists a param name (--flag) that does not exist among the compiled input fields. The compiler looks each relation param up in fieldByName and fails fast so invalid shortcut definitions never reach runtime. It is a definition-contract violation, not a runtime user error.","triggerScenarios":"Registering a shortcut whose typedDefinition has a Relation with Params containing a flag name that is not declared as an input field (typo, removed field, or casing mismatch).","commonSituations":"A field was renamed or deleted from the input struct but the relation still lists the old name; copy-pasting a relation from another shortcut whose params differ; adding a relation before adding the corresponding field.","solutions":["Add the referenced param as a declared input field in the same typed definition","Fix the typo / casing in the relation's Params entry to match an existing field name","Remove the stale param from the relation if the field no longer exists"],"exampleFix":"// before\nRelations: []Relation{{Kind: \"lookup\", Params: []string{\"--chat-id\"}}}\n// (input fields only declare --chat_id)\n// after\nRelations: []Relation{{Kind: \"lookup\", Params: []string{\"--chat_id\"}}}","handlingStrategy":"validation","validationCode":"for _, rel := range def.Input.Relations {\n  for _, name := range rel.Params {\n    if _, ok := fieldNames[name]; !ok {\n      return fmt.Errorf(\"relation references undeclared param %q\", name)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"if err := common.CompileTypedDefinition(def); err != nil {\n  var cerr *common.CompileError\n  if errors.As(err, &cerr) { log.Fatalf(\"invalid definition: %v\", err) }\n  return err\n}","preventionTips":["Derive relation Params from the same field list as the input definition, not hand-typed strings","Add a unit test that compiles every shortcut definition","Grep for removed field names in Relations after refactors"],"tags":["go","shortcut-definition","validation","compile-time"],"backgroundTag":"shortcut-definition-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"}