netbirdio/netbird · error

generate debug bundle: %w

Error message

generate debug bundle: %w

What it means

In Android DebugBundle, after dependencies are gathered, debug.NewBundleGenerator().Generate() collects logs and system info and writes the archive into the configured TempDir (the platform cache dir). Any failure in that collection or write is wrapped as this error, with the underlying cause preserved via %w.

Source

Thrown at client/android/client.go:342

			}
			if cm := e.GetClientMetrics(); cm != nil {
				deps.ClientMetrics = cm
			}
		}
	}

	bundleGenerator := debug.NewBundleGenerator(
		deps,
		debug.BundleConfig{
			Anonymize:         anonymize,
			AnonymizeLevel:    nbAnonymize.ParseLevel(anonymizeLevel),
			IncludeSystemInfo: true,
		},
	)

	path, err := bundleGenerator.Generate()
	if err != nil {
		return "", fmt.Errorf("generate debug bundle: %w", err)
	}
	defer func() {
		if err := os.Remove(path); err != nil {
			log.Errorf("failed to remove debug bundle file: %v", err)
		}
	}()

	uploadCtx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
	defer cancel()

	key, err := debug.UploadDebugBundle(uploadCtx, types.DefaultBundleURL, cfg.ManagementURL.String(), path, false)
	if err != nil {
		return "", fmt.Errorf("upload debug bundle: %w", err)
	}

	log.Infof("debug bundle uploaded with key %s", key)
	return key, nil
}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Ensure the cache directory exists and is writable before triggering the debug bundle.
  2. Free disk space on the device and retry.
  3. Inspect the wrapped cause with errors.Unwrap or %-v formatting to identify the failing file.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the bundle output directory exists before generating
if err := os.MkdirAll(cacheDir, 0o700); err != nil {
    return fmt.Errorf("prepare cache dir: %w", err)
}

Try / catch

path, err := client.DebugBundle(files, true, "anonymize")
if err != nil && strings.HasPrefix(err.Error(), "generate debug bundle:") {
    // disk/cache problem: free space, verify cache dir writable, then retry once
}

Prevention

When it happens

Trigger: The cache dir (platformFiles.CacheDir()) missing, evicted, or read-only; disk full while writing the archive; a source file the generator reads (state file, status) disappearing mid-collection.

Common situations: Android evicting the cache directory while the app is backgrounded; low-storage devices; file-permission changes after an app update.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/a18e758c2900e648. Report an issue: GitHub.