{"record":{"id":"005f34f6ca17895a","repo":"larksuite/cli","slug":"command-set-d-command-d-metadata-service-q-doe","errorCode":null,"errorMessage":"command set %d command %d: Metadata.Service %q does not match domain %q","messagePattern":"command set (.+?) command (.+?): Metadata\\.Service %q does not match domain %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/commandhost/compile.go","lineNumber":50,"sourceCode":"\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)\n\t\t}\n\t}\n\treturn compiled, nil\n}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/commandhost/compile.go#L32-L68","documentation":"CompileSets enforces that each command's Metadata.Service matches its set's domain name, rejecting mismatches with both indices and values. It also derives the canonical shortcut path (Service + \" \" + Command) from these fields, so an inconsistency would produce wrong command paths — hence the hard check.","triggerScenarios":"Registering a command whose definition.Metadata.Service (via command.InspectCommand) differs from set.Domain, e.g. reusing a command declaration from another domain's set or editing Metadata.Service manually.","commonSituations":"Copy-pasting a command declaration into a different domain's shortcut set without updating Metadata.Service; renaming a domain without updating command metadata; plugin commands registered under the wrong domain set.","solutions":["Set Metadata.Command/Metadata.Service on the declaration to match the owning domain","Move the declaration into the set whose Domain equals its Metadata.Service","Use the domain's exported Domain constant for Metadata.Service instead of a string literal"],"exampleFix":"// before\n// in im shortcuts set\nMetadata: common.Metadata{Service: \"contact\", Command: \"chat:list\"}\n// after\nMetadata: common.Metadata{Service: \"im\", Command: \"chat:list\"}\n","handlingStrategy":"validation","validationCode":"// before CompileSets:\nfor i, s := range sets {\n    d := command.InspectDomain(s.Domain)\n    for j, c := range s.Commands {\n        m := command.InspectCommand(c).Metadata\n        if string(m.Service) != d.Name {\n            return fmt.Errorf(\"set %d cmd %d: Service %q != domain %q\", i+1, j+1, m.Service, d.Name)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := commandhost.CompileSets(sets); err != nil {\n    return fmt.Errorf(\"shortcut registration failed: %w\", err) // reports indices and both values\n}","preventionTips":["Set Metadata.Service from the domain's exported constant, never a literal","Cover each shortcuts package with a compile test (TestBusinessDefinitionsCompileTogether pattern)","When moving a declaration between domains, update Metadata.Service in the same change"],"tags":["command-registration","metadata","shortcut"],"backgroundTag":"service-domain-mismatch","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"}