{"record":{"id":"8851576ffdf78f3d","repo":"ipfs/kubo","slug":"generating-profile-data-for-q-w","errorCode":null,"errorMessage":"generating profile data for %q: %w","messagePattern":"generating profile data for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"profile/profile.go","lineNumber":168,"sourceCode":"\tresults := make(chan profileResult, len(p.opts.Collectors))\n\twg := sync.WaitGroup{}\n\tfor _, c := range collectorsToRun {\n\t\tif !c.enabledFunc(p.opts) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfName := c.outputFileName()\n\n\t\twg.Add(1)\n\t\tgo func(c collector) {\n\t\t\tdefer wg.Done()\n\t\t\tlogger.Infow(\"collecting profile\", \"File\", fName)\n\t\t\tdefer logger.Infow(\"profile done\", \"File\", fName)\n\t\t\tb := bytes.Buffer{}\n\t\t\terr := c.collectFunc(ctx, p.opts, &b)\n\t\t\tif err != nil {\n\t\t\t\tselect {\n\t\t\t\tcase results <- profileResult{err: fmt.Errorf(\"generating profile data for %q: %w\", fName, err)}:\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase results <- profileResult{buf: &b, fName: fName}:\n\t\t\tcase <-ctx.Done():\n\t\t\t}\n\t\t}(c)\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(results)\n\t}()\n\n\tfor res := range results {\n\t\tif res.err != nil {\n\t\t\treturn res.err","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/profile/profile.go#L150-L186","documentation":"In profile.WriteProfiles, each named profile is collected concurrently by calling c.collectFunc(ctx, p.opts, &b), which runs a pprof/realtime collector and writes the profile bytes into a buffer. If any collector returns an error, it is wrapped with the profile's archive file name (fName) and sent over the results channel so runProfile aborts with it. It means one specific profile (e.g. heap, goroutine, mutex) could not be generated, not that the whole archive machinery failed.","triggerScenarios":"Calling WriteProfiles when a collector fails: e.g. opts.RequestGoroutineStackDump rejected, runtime/pprof lookup of an unknown profile name, an unsupported Options value (invalid MutexProfileFraction or ProfileFraction), or the passed ctx already cancelled/expired before collection starts.","commonSituations":"Diagnostics bundles (ipfs profile dumps) taken with a bad options struct; profile collection during shutdown when ctx is already done; custom collectFunc plugins that return errors on platforms lacking runtime support (e.g. some sandboxed/container runtimes).","solutions":["Read the wrapped inner error and the quoted fName to identify which collector failed and why","Check the Options struct passed to WriteProfiles: profile fractions must be >= 0 and requested profiles must exist at runtime","Ensure the ctx passed to WriteProfiles is alive for the whole collection duration","Disable or fix the failing collector in the profile list before retrying"],"exampleFix":"// before\ncollectFunc: func(ctx context.Context, opts Options, w io.Writer) error {\n    return pprof.Lookup(opts.ProfileName).WriteTo(w, opts.Debug) // panics/errs on unknown name\n}\n// after\ncollectFunc: func(ctx context.Context, opts Options, w io.Writer) error {\n    p := pprof.Lookup(opts.ProfileName)\n    if p == nil {\n        return fmt.Errorf(\"unknown profile %q\", opts.ProfileName)\n    }\n    return p.WriteTo(w, opts.Debug)\n}","handlingStrategy":"try-catch","validationCode":"if ctx.Err() != nil {\n    return fmt.Errorf(\"cannot collect profiles: %w\", ctx.Err())\n}\nfor _, c := range collectors {\n    if err := c.Validate(opts); err != nil {\n        return fmt.Errorf(\"invalid profile options: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := WriteProfiles(ctx, p)\nif err != nil {\n    var fname string\n    if n, serr := fmt.Sscanf(err.Error(), \"generating profile data for %q\", &fname); serr == nil && n == 1 {\n        log.Printf(\"profile %s failed: %v\", fname, errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Pass a live, non-cancelled context covering the full collection window","Validate Options fields (fractions >= 0, known profile names) before calling WriteProfiles","Keep the profile collector list limited to profiles supported on the target platform","Test diagnostics collection on your runtime environment (containers, sandboxes) once during setup"],"tags":["diagnostics","pprof","go","concurrency"],"backgroundTag":"profile-data-generation-failed","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}