{"record":{"id":"81baab971929a26c","repo":"larksuite/cli","slug":"command-set-d-command-d-command-path-q-conflic","errorCode":null,"errorMessage":"command set %d command %d: command path %q conflicts with %s","messagePattern":"command set (.+?) command (.+?): command path %q conflicts with (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/commandhost/compile.go","lineNumber":55,"sourceCode":"\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)\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.","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/commandhost/compile.go#L37-L73","documentation":"CompileSets builds the flat list of Shortcut commands from registered command sets. Every compiled command must own a unique 'service command' path; when a second definition produces the same path as one already registered, compilation aborts so an ambiguous route can never reach dispatch.","triggerScenarios":"Registering two HostDefinitions in (possibly different) command sets whose Metadata.Service plus Metadata.Command collide, e.g. two shortcuts both named 'doc create' or a service value that duplicates a core command's path.","commonSituations":"Copy-pasting an existing shortcut definition and forgetting to rename it; a plugin/extension contributing a set that overlaps a built-in domain; renaming Metadata.Command in one place but leaving a stale duplicate.","solutions":["Rename the duplicate definition's Metadata.Command so the path is unique","Change Metadata.Service on one of the conflicting definitions to a distinct domain","Search all command set registrations for the path printed in the error and remove the stale duplicate"],"exampleFix":"// before\nMetadata: command.Metadata{Service: \"doc\", Command: \"create\"}\n// second set\nMetadata: command.Metadata{Service: \"doc\", Command: \"create\"}\n// after\nMetadata: command.Metadata{Service: \"doc\", Command: \"create\"}\nMetadata: command.Metadata{Service: \"doc\", Command: \"create-from-template\"}","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, def := range defs {\n    p := string(def.Metadata.Service) + \" \" + def.Metadata.Command\n    if seen[p] { return fmt.Errorf(\"duplicate command path %q\", p) }\n    seen[p] = true\n}","typeGuard":null,"tryCatchPattern":"compiled, err := commandhost.CompileSets(sets)\nif err != nil && strings.Contains(err.Error(), \"conflicts with\") {\n    return fmt.Errorf(\"fix duplicate shortcut registration: %w\", err)\n}","preventionTips":["Keep one registry/source of truth for command paths","Add a compile-time or test assertion that all Metadata.Service+Command pairs are unique","Never copy a HostDefinition without renaming its Metadata.Command"],"tags":["go","cli","command-registration","duplicate-path"],"backgroundTag":"duplicate-command-path","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"}