netbirdio/netbird · error

add sync response: %w

Error message

add sync response: %w

What it means

Returned by BundleGenerator.createArchive in client/internal/debug/debug.go:451 when addSyncResponse fails. Unlike optional entries (config, resolved domains, capture, stack trace, state file) whose errors are only logged, a sync-response failure aborts the whole bundle. Inside addSyncResponse the error can come from anonymizeSyncResponse (when anonymization is on), protojson Marshal of the SyncResponse (network_map.json), or the zip write itself.

Source

Thrown at client/internal/debug/debug.go:451

	if err := g.addProf(); err != nil {
		log.Errorf("failed to add profiles to debug bundle: %v", err)
	}

	if err := g.addCPUProfile(); err != nil {
		log.Errorf("failed to add CPU profile to debug bundle: %v", err)
	}

	if err := g.addCaptureFile(); err != nil {
		log.Errorf("failed to add capture file to debug bundle: %v", err)
	}

	if err := g.addStackTrace(); err != nil {
		log.Errorf("failed to add stack trace to debug bundle: %v", err)
	}

	if err := g.addSyncResponse(); err != nil {
		return fmt.Errorf("add sync response: %w", err)
	}

	if err := g.addStateFile(); err != nil {
		log.Errorf("failed to add state file to debug bundle: %v", err)
	}

	if err := g.addCorruptedStateFiles(); err != nil {
		log.Errorf("failed to add corrupted state files to debug bundle: %v", err)
	}

	if err := g.addServiceParams(); err != nil {
		log.Errorf("failed to add service params to debug bundle: %v", err)
	}

	if err := g.addMetrics(); err != nil {
		log.Errorf("failed to add metrics to debug bundle: %v", err)
	}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Regenerate the bundle with the same daemon and CLI version (version skew between CLI and daemon is the most common cause of marshal-stage failures).
  2. Retry without anonymization (level none) to determine whether the failure is in anonymizeSyncResponse or in marshaling/zip writing.
  3. Free space on the temp filesystem to rule out the zip-write path.
  4. If it persists, collect the daemon debug log showing which inner error ('anonymize sync response', 'generate json', or 'add sync response to zip') was wrapped.
Defensive patterns

Strategy: fallback

Validate before calling

// Go: pre-marshal the sync response before bundle generation to catch protojson issues
if deps.SyncResponse != nil {
    if _, err := (protojson.MarshalOptions{AllowPartial: true}).Marshal(deps.SyncResponse); err != nil {
        deps.SyncResponse = nil // fall back to a bundle without network_map.json
    }
}

Try / catch

// Go: degrade gracefully when the optional network map cannot be serialized
if _, err := generator.Generate(); err != nil {
    if strings.Contains(err.Error(), "add sync response") {
        deps.SyncResponse = nil
        generator = debug.NewBundleGenerator(cfg, deps)
        _, err = generator.Generate() // bundle without network_map.json
    }
    if err != nil {
        return err
    }
}

Prevention

When it happens

Trigger: Generating a debug bundle with anonymization enabled when anonymization of the network map errors, or when protojson fails to marshal the SyncResponse (e.g. invalid UTF-8 in a string field or an internally inconsistent message), or when the zip write of network_map.json hits an I/O error.

Common situations: Anonymized bundles on versions where the anonymizer or proto shapes are out of sync; a daemon/CLI version skew passing a SyncResponse the bundle code cannot marshal; low disk space during the network_map.json write.

Related errors


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