larksuite/cli · error

command set %d: %w

Error message

command set %d: %w

What it means

CompileSets validates each registered shortcut command set; when validateDomain rejects the set's domain (unknown/duplicate/inconsistent with existing business domains), it wraps the cause as "command set %d: %w" with a 1-based set index. This is a developer-time registration/compile failure, not a runtime API error.

Source

Thrown at internal/commandhost/compile.go:42

// CompileSets validates and compiles a complete external contribution without registration.
func CompileSets(sets []command.Set) ([]common.Shortcut, error) {
	sets = command.CloneSets(sets)
	if len(sets) == 0 {
		return nil, nil
	}

	builtins := shortcuts.AllShortcuts()
	paths := make(map[string]string, len(builtins))
	for _, shortcut := range builtins {
		paths[shortcut.Service+" "+shortcut.Command] = "built-in command"
	}
	existingDomains := businessDomains()

	compiled := make([]common.Shortcut, 0)
	for setIndex, set := range sets {
		domain := command.InspectDomain(set.Domain)
		if err := validateDomain(domain, existingDomains); err != nil {
			return nil, fmt.Errorf("command set %d: %w", setIndex+1, err)
		}
		if len(set.Commands) == 0 {
			return nil, fmt.Errorf("command set %d for domain %q has no commands", setIndex+1, domain.Name)
		}
		for commandIndex, declaration := range set.Commands {
			definition := command.InspectCommand(declaration)
			if string(definition.Metadata.Service) != domain.Name {
				return nil, fmt.Errorf("command set %d command %d: Metadata.Service %q does not match domain %q",
					setIndex+1, commandIndex+1, definition.Metadata.Service, domain.Name)
			}
			shortcutPath := string(definition.Metadata.Service) + " " + definition.Metadata.Command
			if owner, duplicate := paths[shortcutPath]; duplicate {
				return nil, fmt.Errorf("command set %d command %d: command path %q conflicts with %s",
					setIndex+1, commandIndex+1, shortcutPath, owner)
			}
			shortcut, err := compileCommand(definition)
			if err != nil {
				return nil, fmt.Errorf("command set %d command %d (%s): %w", setIndex+1, commandIndex+1, shortcutPath, err)

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Read the wrapped cause for the exact domain rule violated
  2. Register/declare the domain correctly before compiling the set
  3. Fix the domain name to match the declared business domain
  4. Ensure only one set owns a given domain across the binary

Example fix

// before
common.ShortcutSet{Domain: myDomainPkg.Undeclared}
// after
common.ShortcutSet{Domain: myDomainPkg.Domain}
Defensive patterns

Strategy: validation

When it happens

Trigger: Adding a shortcut whose set.Domain fails validateDomain (unregistered domain, conflicting with existingDomains) so shortcut compilation at startup/registration returns this error.

Common situations: Registering a new shortcuts/<domain> set with a domain not declared via command.InspectDomain; a domain name typo; two packages claiming overlapping domains during plugin/extension registration.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/615a9770536aa739. Report an issue: GitHub.