larksuite/cli · error
PostMount modified Typed command annotations
Error message
PostMount modified Typed command annotations
What it means
PostMount integrity guard: a PostMount hook modified the Typed command's annotations map, which the framework snapshots and treats as immutable after mount.
Source
Thrown at shortcuts/common/typed_mount_guard.go:76
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]
afterFlag, existsAfter := after.flags[name]
switch {
case !existedBefore:View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Do not mutate annotations in PostMount; declare metadata up front
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shortcuts/common/typed_mount_guard.go:76 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/d249a86e2a62d4a1.
Report an issue: GitHub.