{"id":"1b067c2f3bd730c6","repo":"docker/cli","slug":"failed-to-parse-hook-template-flagvalue-cmd-is-n","errorCode":null,"errorMessage":"failed to parse hook template: flagValue: cmd is nil","messagePattern":"failed to parse hook template: flagValue: cmd is nil","errorType":"exception","errorClass":"ErrHookTemplateParse","httpStatus":null,"severity":"error","filePath":"cli-plugins/hooks/template.go","lineNumber":75,"sourceCode":"// Name returns the name of the (sub)command for which the hook was invoked.\n//\n// It's used for backward-compatibility with old templates.\nfunc (c commandInfo) Name() string {\n\treturn c.command()\n}\n\n// command returns the name of the (sub)command for which the hook was invoked.\nfunc (c commandInfo) command() string {\n\tif c.cmd == nil {\n\t\treturn \"\"\n\t}\n\treturn c.cmd.Name()\n}\n\n// flagValue returns the value that was set for the given flag when the hook was invoked.\nfunc (c commandInfo) flagValue(flagName string) (string, error) {\n\tif c.cmd == nil {\n\t\treturn \"\", fmt.Errorf(\"%w: flagValue: cmd is nil\", ErrHookTemplateParse)\n\t}\n\tf := c.cmd.Flag(flagName)\n\tif f == nil {\n\t\treturn \"\", fmt.Errorf(\"%w: flagValue: no flags found\", ErrHookTemplateParse)\n\t}\n\treturn f.Value.String(), nil\n}\n\n// argValue returns the value of the nth argument.\nfunc (c commandInfo) argValue(n int) (string, error) {\n\tif c.cmd == nil {\n\t\treturn \"\", fmt.Errorf(\"%w: arg: cmd is nil\", ErrHookTemplateParse)\n\t}\n\tflags := c.cmd.Flags()\n\tv := flags.Arg(n)\n\tif v == \"\" && n >= flags.NArg() {\n\t\treturn \"\", fmt.Errorf(\"%w: arg: %dth argument not set\", ErrHookTemplateParse, n)\n\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli-plugins/hooks/template.go#L57-L93","documentation":"Error \"failed to parse hook template: flagValue: cmd is nil\" thrown in docker/cli.","triggerScenarios":"Thrown at cli-plugins/hooks/template.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}