{"record":{"id":"f297af9736c1a531","repo":"hashicorp/packer","slug":"read-verifier-q-w","errorCode":null,"errorMessage":"read verifier %q: %w","messagePattern":"read verifier %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/attestation/sign_key.go","lineNumber":107,"sourceCode":"\t\treturn nil\n\tcase ed25519.PublicKey:\n\t\tif !ed25519.Verify(publicKey, pae, signature) {\n\t\t\treturn fmt.Errorf(\"Ed25519 verification failed\")\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported public key type %T\", v.publicKey)\n\t}\n}\n\nfunc (v *pemVerifier) KeyID() string {\n\treturn v.keyID\n}\n\nfunc LoadPEMVerifier(path string) (Verifier, error) {\n\tcontents, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read verifier %q: %w\", path, err)\n\t}\n\n\tpublicKey, rawVerifier, err := loadPEMPublicKey(contents)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load verifier %q: %w\", path, err)\n\t}\n\n\treturn &pemVerifier{\n\t\tpublicKey: publicKey,\n\t\tkeyID:     sha256Hex(rawVerifier),\n\t}, nil\n}\n\nfunc LoadPEMVerifierBytes(contents []byte) (*pemVerifier, error) {\n\tpublicKey, rawVerifier, err := loadPEMPublicKey(contents)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/attestation/sign_key.go#L89-L125","documentation":"LoadPEMVerifier failed to read the verifier file at the given path because os.ReadFile returned an error. The library wraps the underlying OS error (e.g. *fs.PathError with ENOENT, EACCES) so the cause is preserved via errors.Unwrap. This is a file-access problem, not a key-content problem.","triggerScenarios":"Calling LoadPEMVerifier(path) or any caller (NewVerifier, verifierForEnvelope) with a path that does not exist, is a directory, has too-restrictive permissions, or sits on an unavailable mount.","commonSituations":"Typo in the verifier path in config; file deleted or never provisioned; running the binary as a different user than the key owner; container image missing the mounted key; relative path resolved against an unexpected working directory.","solutions":["Verify the path exists with os.Stat / 'ls -l <path>' and fix typos in the configured path.","Check file permissions and the effective user (chmod/chown or run as a user with read access).","If using a relative path, switch to an absolute path or fix the process working directory.","Inspect the wrapped error with errors.Unwrap or errors.Is(err, fs.ErrNotExist) to identify the exact OS-level cause."],"exampleFix":"// before\nv, err := attestation.LoadPEMVerifier(\"verifier.pem\") // fails: file not found\n// after\nif _, err := os.Stat(\"/etc/packer/verifier.pem\"); err != nil {\n\tlog.Fatal(err)\n}\nv, err := attestation.LoadPEMVerifier(\"/etc/packer/verifier.pem\")","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil {\n\treturn fmt.Errorf(\"verifier file %q unavailable: %w\", path, err)\n}\nif info.IsDir() {\n\treturn fmt.Errorf(\"verifier path %q is a directory\", path)\n}\nf, err := os.Open(path)\nif err != nil {\n\treturn fmt.Errorf(\"verifier file %q not readable: %w\", path, err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":"v, err := attestation.LoadPEMVerifier(path)\nif err != nil {\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\treturn fmt.Errorf(\"verifier file missing at %s\", path)\n\t}\n\tif errors.Is(err, fs.ErrPermission) {\n\t\treturn fmt.Errorf(\"verifier file %s not readable by this user\", path)\n\t}\n\treturn err\n}","preventionTips":["Resolve and validate key paths at config-load time, before signing/verification runs.","Use absolute paths and embed them from a single config source to avoid typos.","In containers, verify secret mounts exist in the entrypoint before starting the app.","Check errors with errors.Is(err, fs.ErrNotExist) / fs.ErrPermission to branch precisely."],"tags":["go","file-io","pem","attestation"],"backgroundTag":"file-not-found","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}