Jguer/yay · error
no keys to import
Error message
no keys to import
What it means
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.
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.
Example fix
// before
if len(keys) == 0 { return "", errors.New("no keys to import") }
// after (caller side)
if len(problematicKeys) > 0 {
if _, err := formatKeysToImport(logger, problematicKeys); err != nil { return err }
} Defensive patterns
Strategy: validation
Validate before calling
if len(problematicKeys) == 0 {
return nil // nothing to import; skip prompt flow entirely
} Try / catch
question, err := formatKeysToImport(logger, keys)
if err != nil {
if strings.Contains(err.Error(), "no keys to import") {
return nil // treat as no-op
}
return err
} Prevention
- 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.
When it happens
Trigger: CheckPgpKeys -> formatKeysToImport with a pgpKeySet of length 0, i.e. the srcinfo parsing produced no problematic keys but the import flow was still entered.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/35b6b6c3f73d64bc.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/sync/srcinfo/pgp/keys.go:110
return problematic.toSlice(), nil
}
// importKeys tries to import the list of keys specified in its argument.
func importKeys(ctx context.Context, logger *text.Logger, cmdBuilder GPGCmdBuilder, keys []string) error {
logger.OperationInfoln(gotext.Get("Importing keys with gpg..."))
if err := cmdBuilder.Show(cmdBuilder.BuildGPGCmd(ctx, append([]string{"--recv-keys"}, keys...)...)); err != nil {
return errors.New(gotext.Get("problem importing keys"))
}
return nil
}
// formatKeysToImport receives a set of keys and returns a string containing the
// question asking the user wants to import the problematic keys.
func formatKeysToImport(logger *text.Logger, keys pgpKeySet) (string, error) {
if len(keys) == 0 {
return "", errors.New(gotext.Get("no keys to import"))
}
var buffer bytes.Buffer
buffer.WriteString(logger.SprintOperationInfo(gotext.Get("PGP keys need importing:")))
for key, bases := range keys {
pkglist := ""
for _, base := range bases {
pkglist += base + " "
}
pkglist = strings.TrimRight(pkglist, " ")
buffer.WriteString("\n" + logger.SprintWarn(gotext.Get("%s, required by: %s", text.Cyan(key), text.Cyan(pkglist))))
}
return buffer.String(), nil
}View on GitHub (pinned to 328f4b4939)