larksuite/cli · error

PostMount modified Typed command metadata or Help text

Error message

PostMount modified Typed command metadata or Help text

What it means

PostMount integrity guard: a PostMount hook changed the Typed command's metadata (Use/Short/Long/Example/aliases) or Help function, which the typed framework owns and forbids mutating.

Source

Thrown at shortcuts/common/typed_mount_guard.go:70

	}
	command.LocalFlags().VisitAll(func(flag *pflag.Flag) {
		annotations := make(map[string][]string, len(flag.Annotations))
		for key, values := range flag.Annotations {
			annotations[key] = append([]string{}, values...)
		}
		snapshot.flags[flag.Name] = typedMountedFlag{
			valueType: flag.Value.Type(), defaultValue: flag.DefValue, usage: flag.Usage,
			shorthand: flag.Shorthand, noOptDefault: flag.NoOptDefVal, deprecated: flag.Deprecated,
			hidden: flag.Hidden, annotations: annotations,
		}
	})
	return snapshot
}

func validateTypedPostMount(command *cobra.Command, before typedMountSnapshot) error {
	after := captureTypedMountSnapshot(command)
	if before.use != after.use || before.short != after.short || before.long != after.long || before.example != after.example || !reflect.DeepEqual(before.aliases, after.aliases) {
		return fmt.Errorf("PostMount modified Typed command metadata or Help text")
	}
	if before.argsFunc != after.argsFunc || before.preRunFunc != after.preRunFunc || before.runFunc != after.runFunc || before.usageFunc != after.usageFunc || before.helpFunc != after.helpFunc {
		return fmt.Errorf("PostMount replaced Typed command validation, execution, or Help functions")
	}
	if !reflect.DeepEqual(before.annotations, after.annotations) {
		return fmt.Errorf("PostMount modified Typed command annotations")
	}
	names := make([]string, 0, len(before.flags)+len(after.flags))
	seen := make(map[string]struct{}, len(before.flags)+len(after.flags))
	for name := range before.flags {
		seen[name] = struct{}{}
		names = append(names, name)
	}
	for name := range after.flags {
		if _, ok := seen[name]; !ok {
			names = append(names, name)
		}
	}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Move metadata changes into the declarative definition; use PostMount only for non-metadata wiring
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/common/typed_mount_guard.go:70 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/d4437c9e71224c6b. Report an issue: GitHub.