larksuite/cli · error

typed shortcut %s %s: %v

Error message

typed shortcut %s %s: %v

What it means

mountDeclarative panics when compiling a typed shortcut definition fails (the %v is the compile error): like other build-time data contracts, a broken shortcut must fail loudly at mount rather than register a malformed command.

Source

Thrown at shortcuts/common/runner.go:929

// Mount registers the shortcut on a parent command.
func (s Shortcut) Mount(parent *cobra.Command, f *cmdutil.Factory) {
	s.MountWithContext(context.Background(), parent, f)
}

// MountWithContext registers a shortcut while preserving the caller-provided context.
func (s Shortcut) MountWithContext(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory) {
	if s.Execute != nil || s.typed != nil {
		s.mountDeclarative(ctx, parent, f)
	}
}

// mountDeclarative builds and registers the Cobra command described by a Shortcut.
func (s Shortcut) mountDeclarative(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory) {
	shortcut := s
	if shortcut.typed != nil {
		if err := validateTypedFlagMountPlan(shortcut.typed, shortcut.PrintFlagSchema != nil, typedRisk(shortcut.Risk)); err != nil {
			panic(fmt.Sprintf("typed shortcut %s %s: %v", shortcut.Service, shortcut.Command, err))
		}
	}
	if len(shortcut.AuthTypes) == 0 {
		shortcut.AuthTypes = []string{"user"}
	}
	botOnly := len(shortcut.AuthTypes) == 1 && shortcut.AuthTypes[0] == "bot"

	cmd := &cobra.Command{
		Use:    shortcut.Command,
		Short:  shortcut.Description,
		Hidden: shortcut.Hidden,
		Args:   rejectPositionalArgs(),
		RunE: func(cmd *cobra.Command, _ []string) error {
			if handled, err := runShortcutFlagSchema(cmd, f, &shortcut); handled {
				return err
			}
			if shortcut.typed != nil {
				return runTypedMountedShortcut(cmd, f, &shortcut, botOnly)

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Fix the shortcut definition per the wrapped compile error and rebuild
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/common/runner.go:929 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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