{"record":{"id":"8c9b9889c9c7dfff","repo":"larksuite/cli","slug":"command-set-d-command-d-s-w","errorCode":null,"errorMessage":"command set %d command %d (%s): %w","messagePattern":"command set (.+?) command (.+?) \\((.+?)\\): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/commandhost/compile.go","lineNumber":60,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"command set %d: %w\", setIndex+1, err)\n\t\t}\n\t\tif len(set.Commands) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"command set %d for domain %q has no commands\", setIndex+1, domain.Name)\n\t\t}\n\t\tfor commandIndex, declaration := range set.Commands {\n\t\t\tdefinition := command.InspectCommand(declaration)\n\t\t\tif string(definition.Metadata.Service) != domain.Name {\n\t\t\t\treturn nil, fmt.Errorf(\"command set %d command %d: Metadata.Service %q does not match domain %q\",\n\t\t\t\t\tsetIndex+1, commandIndex+1, definition.Metadata.Service, domain.Name)\n\t\t\t}\n\t\t\tshortcutPath := string(definition.Metadata.Service) + \" \" + definition.Metadata.Command\n\t\t\tif owner, duplicate := paths[shortcutPath]; duplicate {\n\t\t\t\treturn nil, fmt.Errorf(\"command set %d command %d: command path %q conflicts with %s\",\n\t\t\t\t\tsetIndex+1, commandIndex+1, shortcutPath, owner)\n\t\t\t}\n\t\t\tshortcut, err := compileCommand(definition)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"command set %d command %d (%s): %w\", setIndex+1, commandIndex+1, shortcutPath, err)\n\t\t\t}\n\t\t\tpaths[shortcutPath] = fmt.Sprintf(\"command set %d command %d\", setIndex+1, commandIndex+1)\n\t\t\tcompiled = append(compiled, shortcut)\n\t\t}\n\t}\n\treturn compiled, nil\n}\n\n// ValidateDeclaration compiles one declaration through the production compiler\n// and discards the result. A business test harness calls it so a wrong tag,\n// Shape or relation fails in the unit test rather than at CLI startup: executing\n// hooks directly exercises none of the compiler's contract checks, which is the\n// gap that let a green test ship a command that cannot mount.\n//\n// Domain existence and path collisions are deliberately not checked here. Those\n// are properties of a whole contribution and belong to CompileSets, which runs\n// during build.\nfunc ValidateDeclaration(declaration command.Command) error {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/commandhost/compile.go#L42-L78","documentation":"This wraps any error returned by compileCommand for an individual shortcut definition, adding its position and path for diagnosis. CompileSets fails atomically: one bad definition prevents the whole set from compiling.","triggerScenarios":"A HostDefinition fails internal validation in compileCommand — e.g. invalid hooks, malformed dry-run view, or another definition-level invariant — during CompileSets.","commonSituations":"A newly added shortcut with an incorrectly wired hook or dry-run request view; a refactor changed compileCommand's contract and existing definitions no longer validate.","solutions":["Read the wrapped cause (%w) after this prefix — it names the actual failing invariant","Fix the offending HostDefinition at 'command set N command M' indicated in the message","If the cause is a dry-run request error, fix the view per ValidateRequestView"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate definitions: non-empty Service/Command, hooks and dry-run views populated per command.HostDefinition contract.","typeGuard":null,"tryCatchPattern":"compiled, err := commandhost.CompileSets(sets)\nvar pathErr *fmt.WrapError // or unwrap chain\nif err != nil {\n    return fmt.Errorf(\"compiling business command sets: %w\", err) // preserves the 'command set N command M' context\n}","preventionTips":["Unit-test each new shortcut definition with CompileSets before merging","Use errors.Unwrap / %w chains to surface root causes in logs","Mirror existing passing definitions when adding new ones"],"tags":["go","cli","command-compilation","wrapped-error"],"backgroundTag":"shortcut-compilation-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"}