{"record":{"id":"702393854cffb1e9","repo":"Jguer/yay","slug":"problem-importing-keys","errorCode":null,"errorMessage":"problem importing keys","messagePattern":"problem importing keys","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/srcinfo/pgp/keys.go","lineNumber":100,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlogger.Println(\"\\n\", str)\n\n\tif logger.ContinueTask(gotext.Get(\"Import?\"), true, noConfirm) {\n\t\treturn problematic.toSlice(), importKeys(ctx, logger, cmdBuilder, problematic.toSlice())\n\t}\n\n\treturn problematic.toSlice(), nil\n}\n\n// importKeys tries to import the list of keys specified in its argument.\nfunc importKeys(ctx context.Context, logger *text.Logger, cmdBuilder GPGCmdBuilder, keys []string) error {\n\tlogger.OperationInfoln(gotext.Get(\"Importing keys with gpg...\"))\n\n\tif err := cmdBuilder.Show(cmdBuilder.BuildGPGCmd(ctx, append([]string{\"--recv-keys\"}, keys...)...)); err != nil {\n\t\treturn errors.New(gotext.Get(\"problem importing keys\"))\n\t}\n\n\treturn nil\n}\n\n// formatKeysToImport receives a set of keys and returns a string containing the\n// question asking the user wants to import the problematic keys.\nfunc formatKeysToImport(logger *text.Logger, keys pgpKeySet) (string, error) {\n\tif len(keys) == 0 {\n\t\treturn \"\", errors.New(gotext.Get(\"no keys to import\"))\n\t}\n\n\tvar buffer bytes.Buffer\n\n\tbuffer.WriteString(logger.SprintOperationInfo(gotext.Get(\"PGP keys need importing:\")))\n\n\tfor key, bases := range keys {\n\t\tpkglist := \"\"","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/sync/srcinfo/pgp/keys.go#L82-L118","documentation":"importKeys shells out to gpg (gpg --recv-keys <keys...>) to fetch the PGP keys needed to verify a source package, and wraps any non-zero exit in this generic error. It means gpg could not receive one or more of the requested keys from the configured keyservers.","triggerScenarios":"CheckPgpKeys -> importKeys when cmdBuilder.Show on the built gpg --recv-keys command returns an error: keys already present plus another gpg failure, keyserver unreachable, key not found on any keyserver, or malformed key IDs.","commonSituations":"Building AUR packages whose makepkg validpgpkeys are not in the local keyring; firewalled/offline environments blocking hkp port 11371; keyservers (keyserver.ubuntu.com, pool.sks-keyservers.net) being flaky; key IDs that were revoked or never published.","solutions":["Import the key manually to see the real gpg error: gpg --recv-keys <KEYID>, then re-run the build.","Point gpg at a reliable keyserver, e.g. add keyserver hkp://keyserver.ubuntu.com:80 to ~/.gnupg/dirmngr.conf and restart dirmngr.","Check network access to keyserver ports (11371/hkp or 80); retry if the keyserver was temporarily down.","Verify the key ID in the PKGBUILD's validpgpkeys is correct and still published."],"exampleFix":"// before (keyserver unreachable)\ngpg --recv-keys A5E9D918BCF8F335  # times out -> \"problem importing keys\"\n// after (~/.gnupg/dirmngr.conf)\nkeyserver hkp://keyserver.ubuntu.com:80\n# then: gpg --recv-keys A5E9D918BCF8F335","handlingStrategy":"retry","validationCode":"// pre-check key availability\nfor _, key := range keys {\n    if err := exec.Command(\"gpg\", \"--list-keys\", key).Run(); err != nil {\n        // key not in keyring yet; ensure network/keyserver reachable\n    }\n}","typeGuard":null,"tryCatchPattern":"err := pgp.CheckPgpKeys(ctx, logger, srcinfos, cmdBuilder, noConfirm)\nif err != nil && strings.Contains(err.Error(), \"problem importing keys\") {\n    // surface hint: run gpg --recv-keys <KEYID> manually / check keyserver\n    return fmt.Errorf(\"%w: check network and keyserver config\", err)\n}","preventionTips":["Configure a reliable keyserver in ~/.gnupg/dirmngr.conf.","Pre-import known validpgpkeys before batch builds.","Ensure outbound hkp (11371) or https keyserver access.","Keep gpg/dirmngr updated."],"tags":["gpg","pgp","network","arch-linux"],"backgroundTag":"git-command-failed","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}