{"record":{"id":"952331123abe237c","repo":"getsops/sops","slug":"errors-new-sb-string","errorCode":null,"errorMessage":"errors.New(sb.String())","messagePattern":"errors\\.New\\(sb\\.String\\(\\)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgp/keysource.go","lineNumber":162,"sourceCode":"\t\treturn fmt.Errorf(\"cannot import armored key data into GnuPG keyring: %w\", err)\n\t}\n\n\targs := []string{\"--batch\", \"--import\"}\n\t_, stderr, err := gpgExec(ctx, d.String(), args, bytes.NewReader(armoredKey))\n\tif err != nil {\n\t\tstderrStr := strings.TrimSpace(stderr.String())\n\t\terrStr := err.Error()\n\t\tvar sb strings.Builder\n\t\tsb.WriteString(\"failed to import armored key data into GnuPG keyring\")\n\t\tif len(stderrStr) > 0 {\n\t\t\tif len(errStr) > 0 {\n\t\t\t\tfmt.Fprintf(&sb, \" (%s)\", errStr)\n\t\t\t}\n\t\t\tfmt.Fprintf(&sb, \": %s\", stderrStr)\n\t\t} else if len(errStr) > 0 {\n\t\t\tfmt.Fprintf(&sb, \": %s\", errStr)\n\t\t}\n\t\treturn errors.New(sb.String())\n\t}\n\treturn nil\n}\n\n// ImportFile attempts to import the armored key file into the GnuPGHome\n// keyring.\n// It returns an error if the GnuPGHome does not pass Validate, or if the\n// import failed.\nfunc (d GnuPGHome) ImportFile(path string) error {\n\tb, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot read armored key data from file: %w\", err)\n\t}\n\treturn d.Import(b)\n}\n\n// Cleanup deletes the GnuPGHome if it passes Validate.\n// It returns an error if the GnuPGHome does not pass Validate, or if the","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/pgp/keysource.go#L144-L180","documentation":"Error \"errors.New(sb.String())\" thrown in getsops/sops.","triggerScenarios":"Thrown at pgp/keysource.go:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}