{"record":{"id":"2be38fced2e77d32","repo":"projectdiscovery/nuclei","slug":"could-not-read-profile-file-w","errorCode":null,"errorMessage":"could not read profile file: %w","messagePattern":"could not read profile file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nuclei/main.go","lineNumber":880,"sourceCode":"\t})\n\tif err != nil && err.Error() != \"FOUND\" {\n\t\toptions.Logger.Error().Msgf(\"%s\\n\", err)\n\t}\n\treturn profilePath\n}\n\n// profileSecrets is a helper struct to extract secrets section from a template profile YAML\ntype profileSecrets struct {\n\tSecrets interface{} `yaml:\"secrets\"`\n}\n\n// processInlineSecretsFromProfile parses the profile YAML file for inline secrets\n// and creates a temporary secrets file compatible with nuclei's auth provider.\n// Returns the path to the temp file or empty string if no secrets found.\nfunc processInlineSecretsFromProfile(profilePath string, options *types.Options) (string, error) {\n\tdata, err := os.ReadFile(profilePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not read profile file: %w\", err)\n\t}\n\n\tvar profile profileSecrets\n\tif err := yaml.Unmarshal(data, &profile); err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not parse profile YAML: %w\", err)\n\t}\n\n\tif profile.Secrets == nil {\n\t\treturn \"\", nil\n\t}\n\n\tsecretsData, err := yaml.Marshal(profile.Secrets)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not marshal inline secrets: %w\", err)\n\t}\n\n\ttempDir := filepath.Join(os.TempDir(), \"nuclei-secrets\")\n\tif err := os.MkdirAll(tempDir, 0700); err != nil {","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/cmd/nuclei/main.go#L862-L898","documentation":"processInlineSecretsFromProfile (cmd/nuclei/main.go:880) reads the profile file with os.ReadFile before extracting its `secrets:` section; any read failure is wrapped as 'could not read profile file' with the os error (%w) carrying the exact cause (ENOENT, EACCES, is-a-directory, etc.). It fires at startup when a profile is supplied, before any scanning starts.","triggerScenarios":"Running nuclei with a `-profile` path that does not exist, is a directory, or is unreadable by the current user; a relative profile path resolved from a different working directory.","commonSituations":"Typo'd profile path; profile created by root/another user with restrictive permissions; containers/CI where the profile file was not mounted at the expected path.","solutions":["Confirm the path exists and is a regular file (`ls -l <path>`)","Use an absolute path for the profile file","Fix readability (ownership/chmod) or copy the profile somewhere readable","In containers, verify the volume actually mounts the profile at that path"],"exampleFix":"# before\nnuclei -profile profiles/scan.yaml\n\n# after\nls -l /home/user/profiles/scan.yaml\nnuclei -profile /home/user/profiles/scan.yaml","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(profilePath); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"profile path %q missing or not a file\", profilePath)\n}\n// optional readability probe\nif f, err := os.Open(profilePath); err != nil {\n    return fmt.Errorf(\"profile not readable: %w\", err)\n} else { _ = f.Close() }","typeGuard":null,"tryCatchPattern":"data, err := os.ReadFile(profilePath)\nif err != nil {\n    if errors.Is(err, fs.ErrNotExist) {\n        return fmt.Errorf(\"profile %s does not exist\", profilePath)\n    }\n    if errors.Is(err, fs.ErrPermission) {\n        return fmt.Errorf(\"profile %s not readable by uid %d\", profilePath, os.Getuid())\n    }\n    return err\n}","preventionTips":["Use absolute profile paths in scripts and CI","Check existence and readability of the profile before launching nuclei","Mount/verify profile files explicitly in containers"],"tags":["go","nuclei","configuration","filesystem","cli","profile"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}