{"record":{"id":"006f586d77517954","repo":"FiloSottile/age","slug":"invalid-plugin-name-q","errorCode":null,"errorMessage":"invalid plugin name: %q","messagePattern":"invalid plugin name: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/client.go","lineNumber":193,"sourceCode":"\tui       *ClientUI\n}\n\nvar _ age.Identity = &Identity{}\n\nfunc NewIdentity(s string, ui *ClientUI) (*Identity, error) {\n\tname, _, err := ParseIdentity(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Identity{\n\t\tname: name, encoding: s, ui: ui,\n\t}, nil\n}\n\nfunc NewIdentityWithoutData(name string, ui *ClientUI) (*Identity, error) {\n\ts := EncodeIdentity(name, nil)\n\tif s == \"\" {\n\t\treturn nil, fmt.Errorf(\"invalid plugin name: %q\", name)\n\t}\n\treturn &Identity{\n\t\tname: strings.ToLower(name), encoding: s, ui: ui,\n\t}, nil\n}\n\n// Name returns the plugin name, which is used in the recipient (\"age1name1...\")\n// and identity (\"AGE-PLUGIN-NAME-1...\") encodings, as well as in the plugin\n// binary name (\"age-plugin-name\").\nfunc (i *Identity) Name() string {\n\treturn i.name\n}\n\n// String returns the identity encoding string (\"AGE-PLUGIN-NAME-1...\").\nfunc (i *Identity) String() string {\n\treturn i.encoding\n}\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/plugin/client.go#L175-L211","documentation":"NewIdentityWithoutData validates the plugin name by checking that EncodeIdentity(name, nil) produces a non-empty identity encoding. If it returns empty, the name is not a recognized/supported plugin identity name and construction fails, preventing Identity objects for plugins that cannot encode identities.","triggerScenarios":"Calling NewIdentityWithoutData with a name whose prefix has no registered identity encoding: an empty string, a misspelled plugin name, or a plugin that only supports recipients (no identity scheme). Called by encryptNotPass/decryptNotPass and tests.","commonSituations":"Typo in the plugin name in config or code; using a recipient-only plugin with the identity constructor; a library version that does not know the plugin's identity encoding; empty name from an unset environment variable or config key.","solutions":["Pass the exact supported plugin name and check for typos or stray whitespace.","Confirm the plugin supports identities; recipient-only plugins cannot be used with NewIdentityWithoutData.","Reject empty/blank names at config load time before calling.","If the plugin is legitimate but unsupported, upgrade the age library/plugin to a version that knows its identity encoding."],"exampleFix":"// before\nname := os.Getenv(\"AGE_PLUGIN\") // may be \"\"\nidentity, err := age.NewIdentityWithoutData(name, ui) // invalid plugin name: \"\"\n// after\nname := strings.TrimSpace(os.Getenv(\"AGE_PLUGIN\"))\nif name == \"\" {\n    return fmt.Errorf(\"AGE_PLUGIN must be set to a supported plugin name\")\n}\nidentity, err := age.NewIdentityWithoutData(name, ui)","handlingStrategy":"validation","validationCode":"// Go: validate the plugin name before constructing the identity\nname := strings.TrimSpace(cfg.PluginName)\nif name == \"\" {\n    return fmt.Errorf(\"plugin name must not be empty\")\n}","typeGuard":"func validPluginName(name string) bool {\n    return name != \"\" && strings.TrimSpace(name) == name &&\n        plugin.EncodeIdentity(name, nil) != \"\" // maps to a known identity encoding\n}","tryCatchPattern":"identity, err := plugin.NewIdentityWithoutData(name, ui)\nif err != nil {\n    return fmt.Errorf(\"unsupported plugin identity %q: %w\", name, err)\n}","preventionTips":["Trim and validate plugin names at config load time.","Only use plugin names whose plugins support identity encoding (not recipient-only).","Keep the plugin and age library versions aligned so all prefixes are known.","Reject empty/whitespace names early with a clear configuration error."],"tags":["go","age","plugin","validation","invalid-input"],"backgroundTag":"invalid-plugin-name","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}