larksuite/cli · error

PostMount replaced Typed command validation, execution, or H

Error message

PostMount replaced Typed command validation, execution, or Help functions

What it means

PostMount integrity guard: a PostMount hook replaced the Typed command's Validate/E (execution) or Help function pointers, bypassing the compiled typed pipeline.

Source

Thrown at shortcuts/common/typed_mount_guard.go:73

		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)
		}
	}
	sort.Strings(names)
	for _, name := range names {
		beforeFlag, existedBefore := before.flags[name]

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Hook execution via the framework's extension points instead of overwriting the funcs
Defensive patterns

Strategy: validation

When it happens

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