{"record":{"id":"ca2d26fb52f93e86","repo":"larksuite/cli","slug":"command-set-d-for-domain-q-has-no-commands","errorCode":null,"errorMessage":"command set %d for domain %q has no commands","messagePattern":"command set (.+?) for domain %q has no commands","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/commandhost/compile.go","lineNumber":45,"sourceCode":"\tif len(sets) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tbuiltins := shortcuts.AllShortcuts()\n\tpaths := make(map[string]string, len(builtins))\n\tfor _, shortcut := range builtins {\n\t\tpaths[shortcut.Service+\" \"+shortcut.Command] = \"built-in command\"\n\t}\n\texistingDomains := businessDomains()\n\n\tcompiled := make([]common.Shortcut, 0)\n\tfor setIndex, set := range sets {\n\t\tdomain := command.InspectDomain(set.Domain)\n\t\tif err := validateDomain(domain, existingDomains); err != nil {\n\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)","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/commandhost/compile.go#L27-L63","documentation":"CompileSets requires every command set to declare at least one command. A set whose Commands slice is empty cannot contribute a runnable command path, so compilation fails with the set index and its domain name. It fails atomically — no partial compilation result is returned.","triggerScenarios":"Registering common.ShortcutSet with a valid Domain but zero entries in Commands; building the slice conditionally such that all commands are filtered out before CompileSets runs.","commonSituations":"A new shortcuts package stubbed with an empty Shortcuts() list; feature-flag filtering that removes every command; refactoring that renamed command constructors leaving the slice empty.","solutions":["Add at least one command declaration to the set's Commands slice","Remove the set registration entirely if the domain has no commands yet","Check whether build-tag or config filtering emptied the slice unintentionally"],"exampleFix":"// before\nsets := []common.ShortcutSet{{Domain: myDomain}} // no commands\n// after\nsets := []common.ShortcutSet{{Domain: myDomain, Commands: []common.CommandDeclaration{myCmd}}}\n","handlingStrategy":"validation","validationCode":"// before CompileSets:\nfor i, s := range sets {\n    if len(s.Commands) == 0 { return fmt.Errorf(\"set %d (%v) declares no commands\", i+1, s.Domain) }\n}","typeGuard":null,"tryCatchPattern":"if _, err := commandhost.CompileSets(sets); err != nil {\n    return fmt.Errorf(\"shortcut registration failed: %w\", err) // surfaces set index + domain\n}","preventionTips":["Assert len(Shortcuts()) > 0 in each shortcuts package test","Avoid conditional filtering that can empty the command list","Register a placeholder-free set only when commands exist"],"tags":["command-registration","shortcut","empty-command-set"],"backgroundTag":"empty-command-set","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"}