{"record":{"id":"326196c691bec27f","repo":"getsops/sops","slug":"failed-to-read-s-file-too-long","errorCode":null,"errorMessage":"failed to read '%s': file too long","messagePattern":"failed to read '(.+?)': file too long","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"age/encrypted_keys.go","lineNumber":127,"sourceCode":"func unwrapIdentities(location string, reader io.Reader, allowMultipleKeysPerLine bool) (ParsedIdentities, error) {\n\tb := bufio.NewReader(reader)\n\tp, _ := b.Peek(14) // length of \"age-encryption\" and \"-----BEGIN AGE\"\n\tpeeked := string(p)\n\n\tswitch {\n\t// An age encrypted file, plain or armored.\n\tcase peeked == \"age-encryption\" || peeked == \"-----BEGIN AGE\":\n\t\tvar r io.Reader = b\n\t\tif peeked == \"-----BEGIN AGE\" {\n\t\t\tr = armor.NewReader(r)\n\t\t}\n\t\tconst privateKeySizeLimit = 1 << 24 // 16 MiB\n\t\tcontents, err := io.ReadAll(io.LimitReader(r, privateKeySizeLimit))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read '%s': %w\", location, err)\n\t\t}\n\t\tif len(contents) == privateKeySizeLimit {\n\t\t\treturn nil, fmt.Errorf(\"failed to read '%s': file too long\", location)\n\t\t}\n\t\t// We use Base32 encoding instead of Base64 encoding, since our GPG agent package percent-encodes\n\t\t// the cache ID. Base64 has two characters ('+' and '/') that would end up as a longer sequence,\n\t\t// whence using Base64 encoding can suddenly blow up the cache key to more than GPG's maximum of\n\t\t// 50 characters.\n\t\t// By using 25 bytes, that translate to 25 / 5 * 8 = 40 letters/digits, we have a cache key of\n\t\t// length 47, whose percent-encoding always has 47 characters.\n\t\tcontentsHash := sha256.Sum256(contents)\n\t\tcacheKey := fmt.Sprintf(\"SopsAge%s\", base32.StdEncoding.EncodeToString(contentsHash[:25]))\n\t\tIncorrectPassphrase := func() {\n\t\t\tconn, err := gpgagent.NewConn()\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer func(conn *gpgagent.Conn) {\n\t\t\t\tif err := conn.Close(); err != nil {\n\t\t\t\t\tlog.Errorf(\"failed to close connection with gpg-agent: %s\", err)\n\t\t\t\t}","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/age/encrypted_keys.go#L109-L145","documentation":"Error \"failed to read '%s': file too long\" thrown in getsops/sops.","triggerScenarios":"Thrown at age/encrypted_keys.go:127 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"}