{"record":{"id":"35b6b6c3f73d64bc","repo":"Jguer/yay","slug":"no-keys-to-import","errorCode":null,"errorMessage":"no keys to import","messagePattern":"no keys to import","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/srcinfo/pgp/keys.go","lineNumber":110,"sourceCode":"\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 := \"\"\n\t\tfor _, base := range bases {\n\t\t\tpkglist += base + \"  \"\n\t\t}\n\n\t\tpkglist = strings.TrimRight(pkglist, \" \")\n\t\tbuffer.WriteString(\"\\n\" + logger.SprintWarn(gotext.Get(\"%s, required by: %s\", text.Cyan(key), text.Cyan(pkglist))))\n\t}\n\n\treturn buffer.String(), nil\n}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/sync/srcinfo/pgp/keys.go#L92-L128","documentation":"formatKeysToImport builds the user-facing question listing PGP keys to import; it guards against being handed an empty key set and returns this error when there is nothing to import. It is an internal invariant: CheckPgpKeys should only call it when problematic keys were collected.","triggerScenarios":"CheckPgpKeys -> formatKeysToImport with a pgpKeySet of length 0, i.e. the srcinfo parsing produced no problematic keys but the import flow was still entered.","commonSituations":"Programmatic use of the srcinfo service with an empty/edge-case srcinfo input; a logic bug upstream where the key filter already removed everything before prompting; weird PKGBUILDs with no validpgpkeys passing through the check path.","solutions":["Check upstream that keys were collected before prompting; only call the PGP-import flow when the pgpKeySet is non-empty.","If you hit it as a user, re-run the operation; if reproducible, it indicates a yay bug — report it with the PKGBUILD/srcinfo involved.","Verify the PKGBUILD's validpgpkeys array is well-formed (non-empty hex IDs) if you authored it."],"exampleFix":"// before\nif len(keys) == 0 { return \"\", errors.New(\"no keys to import\") }\n// after (caller side)\nif len(problematicKeys) > 0 {\n    if _, err := formatKeysToImport(logger, problematicKeys); err != nil { return err }\n}","handlingStrategy":"validation","validationCode":"if len(problematicKeys) == 0 {\n    return nil // nothing to import; skip prompt flow entirely\n}","typeGuard":null,"tryCatchPattern":"question, err := formatKeysToImport(logger, keys)\nif err != nil {\n    if strings.Contains(err.Error(), \"no keys to import\") {\n        return nil // treat as no-op\n    }\n    return err\n}","preventionTips":["Only enter the PGP prompt flow when keys were collected.","Validate srcinfo pgpkeys arrays before processing.","Treat empty key sets as a no-op, not an error path, in wrappers."],"tags":["gpg","pgp","internal-invariant","arch-linux"],"backgroundTag":"empty-required-field","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"}