{"record":{"id":"e7c824586400bdb7","repo":"FiloSottile/age","slug":"client-failed-to-request-value","errorCode":null,"errorMessage":"client failed to request value","messagePattern":"client failed to request value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/plugin.go","lineNumber":538,"sourceCode":"// RequestValue requests a secret or public input from the user through the\n// client, with the provided prompt. It returns an error if the client can't\n// request the input or if the user dismisses the prompt.\n//\n// It must only be called by a Wrap or Unwrap method invoked by [Plugin.Main].\nfunc (p *Plugin) RequestValue(prompt string, secret bool) (string, error) {\n\tt := \"request-public\"\n\tif secret {\n\t\tt = \"request-secret\"\n\t}\n\tif err := writeStanzaWithBody(p.stdout, t, []byte(prompt)); err != nil {\n\t\treturn \"\", p.fatalInteractf(\"failed to write stanza: %v\", err)\n\t}\n\ts, err := readOkOrFail(p.sr)\n\tif err != nil {\n\t\treturn \"\", p.fatalInteractf(\"%v\", err)\n\t}\n\tif s.Type == \"fail\" {\n\t\treturn \"\", fmt.Errorf(\"client failed to request value\")\n\t}\n\tif err := expectStanzaWithAnyBody(s, 0); err != nil {\n\t\treturn \"\", p.fatalInteractf(\"%v\", err)\n\t}\n\treturn string(s.Body), nil\n}\n\n// Confirm requests a confirmation from the user through the client, with the\n// provided prompt. The yes and no value are the choices provided to the user.\n// no may be empty. The return value choseYes indicates whether the user\n// selected the yes or no option. Confirm returns an error if the client can't\n// request the confirmation.\n//\n// It must only be called by a Wrap or Unwrap method invoked by [Plugin.Main].\nfunc (p *Plugin) Confirm(prompt, yes, no string) (choseYes bool, err error) {\n\targs := []string{format.EncodeToString([]byte(yes))}\n\tif no != \"\" {\n\t\targs = append(args, format.EncodeToString([]byte(no)))","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/plugin/plugin.go#L520-L556","documentation":"RequestValue asks the age client to prompt the user for a secret value via the request-value protocol command. This error means the client replied with a \"fail\" stanza — it could not obtain the requested value. The plugin gets an error instead of a value string.","triggerScenarios":"The client cannot prompt (non-interactive session, no TTY, GUI unavailable); the client rejects the message or request for some reason; the user cancels in a way the client maps to fail.","commonSituations":"PIN/passphrase request for a hardware token in a headless CI run; old age client without request-value support; automated scripts with no interactive input available.","solutions":["Provide the value out of band (e.g. rely on the client's own -i/passphrase mechanisms) or degrade gracefully when the request fails","Run age interactively so the client can prompt the user","Upgrade the age client to a version implementing request-value"],"exampleFix":"// before\npin, err := p.RequestValue(false, \"PIN\")\nif err != nil { return err }\n// after\npin, err := p.RequestValue(false, \"PIN\")\nif err != nil {\n    if env := os.Getenv(\"PLUGIN_PIN\"); env != \"\" { pin = env } else { return err }\n}","handlingStrategy":"try-catch","validationCode":"// Ensure an interactive prompt source exists before requesting:\n// if os.Getenv(\"CI\") != \"\" { skip RequestValue and use env/config instead }","typeGuard":null,"tryCatchPattern":"val, err := p.RequestValue(false, \"PIN\")\nif err != nil {\n    if strings.Contains(err.Error(), \"client failed to request value\") {\n        // fall back to env var or fail with clear guidance\n    }\n    return err\n}","preventionTips":["Provide out-of-band secret sources (env vars, config) for CI","Request values only when interaction is possible","Test plugins in non-interactive mode"],"tags":["age","plugin","prompt","client-interaction"],"backgroundTag":"plugin-client-interaction-failed","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}