{"record":{"id":"817c3bf9bd6f800f","repo":"hashicorp/nomad","slug":"pprof-profile-not-found-profile","errorCode":"Pprof profile not found profile:","errorMessage":"%s %s","messagePattern":"%s %s","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"command/agent/pprof/pprof.go","lineNumber":37,"sourceCode":"\t\"strings\"\n\t\"time\"\n)\n\ntype ReqType string\n\nconst (\n\tCmdReq    ReqType = \"cmdline\"\n\tCPUReq    ReqType = \"cpu\"\n\tTraceReq  ReqType = \"trace\"\n\tLookupReq ReqType = \"lookup\"\n\n\tErrProfileNotFoundPrefix = \"Pprof profile not found profile:\"\n)\n\n// NewErrProfileNotFound returns a new error caused by a pprof.Lookup\n// profile not being found\nfunc NewErrProfileNotFound(profile string) error {\n\treturn fmt.Errorf(\"%s %s\", ErrProfileNotFoundPrefix, profile)\n}\n\n// IsErrProfileNotFound returns whether the error is due to a pprof profile\n// being invalid\nfunc IsErrProfileNotFound(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), ErrProfileNotFoundPrefix)\n}\n\n// Cmdline responds with the running program's\n// command line, with arguments separated by NUL bytes.\nfunc Cmdline() ([]byte, map[string]string, error) {\n\tvar buf bytes.Buffer\n\tfmt.Fprint(&buf, strings.Join(os.Args, \"\\x00\"))\n\n\treturn buf.Bytes(),\n\t\tmap[string]string{\n\t\t\t\"X-Content-Type-Options\": \"nosniff\",\n\t\t\t\"Content-Type\":           \"text/plain; charset=utf-8\",","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/pprof/pprof.go#L19-L55","documentation":"Nomad's agent command package exposes pprof runtime profiles via HTTP. NewErrProfileNotFound wraps a failed pprof.Lookup(name) call, i.e. the requested profile name does not exist among Go's registered pprof profiles (goroutine, heap, allocs, threadcreate, block, mutex, trace, etc.). IsErrProfileNotFound detects it by string-matching the prefix 'Pprof profile not found profile:'.","triggerScenarios":"An HTTP request to the agent's pprof endpoint with an unrecognized profile name path (e.g. /debug/pprof/bogus), causing pprof.Lookup(name) to return nil and Profile to call NewErrProfileNotFound(profile).","commonSituations":"Typo in a profiling URL (heap vs heep), requesting a Go profile that requires a runtime build tag or is not registered (e.g. 'trace' vs 'cpuprofile'), automated tooling scraping a profile name not present in the Nomad agent's Go version.","solutions":["Fix the profile name in the request URL to a valid pprof.Lookup name (goroutine, heap, allocs, threadcreate, block, mutex, trace)","List available profiles by querying the pprof index page at /debug/pprof/ to see valid names","If using a tool/scraper, update its profile list to match the runtime's registered profiles","Check IsErrProfileNotFound(err) and return 404 to callers instead of a 500"],"exampleFix":"// before\ncurl http://localhost:4646/debug/pprof/heaps\n// after\ncurl http://localhost:4646/debug/pprof/heap","handlingStrategy":"try-catch","validationCode":"valid := map[string]bool{\"goroutine\":true,\"heap\":true,\"allocs\":true,\"threadcreate\":true,\"block\":true,\"mutex\":true,\"trace\":true}\nif !valid[profileName] { return fmt.Errorf(\"unknown pprof profile: %s\", profileName) }","typeGuard":"func IsErrProfileNotFound(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"Pprof profile not found profile:\")\n}","tryCatchPattern":"prof, err := Profile(name)\nif err != nil {\n\tif IsErrProfileNotFound(err) {\n\t\t// treat as 404 / skip profile\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Use only names accepted by runtime/pprof's pprof.Lookup","Browse /debug/pprof/ index to discover valid profile names","Handle IsErrProfileNotFound as a 404 in HTTP handlers","Pin scraper tooling to profiles available in the agent's Go version"],"tags":["pprof","http","profiling","nomad"],"backgroundTag":"resource-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}