netbirdio/netbird · error

get sync response: %w

Error message

get sync response: %w

What it means

Returned by Client.GetLatestSyncResponse when Engine.GetLatestSyncResponse fails. The engine returns "sync response persistence is disabled" when no sync store is configured, and the store's Get can fail on read/parse errors. The embedded client enables sync persistence (SetSyncResponsePersistence(true)) in Start, so on a healthy started client the store exists and the error means either persistence was not enabled on this engine or the stored state could not be read.

Source

Thrown at client/embed/embed.go:489

		engine := connect.Engine()
		if engine != nil {
			_ = engine.RunHealthProbes(context.Background(), false)
		}
	}

	return c.recorder.GetFullStatus(), nil
}

// GetLatestSyncResponse returns the latest sync response from the management server.
func (c *Client) GetLatestSyncResponse() (*mgmProto.SyncResponse, error) {
	engine, err := c.getEngine()
	if err != nil {
		return nil, err
	}

	syncResp, err := engine.GetLatestSyncResponse()
	if err != nil {
		return nil, fmt.Errorf("get sync response: %w", err)
	}

	return syncResp, nil
}

// SetLogLevel sets the logging level for the client and its components.
func (c *Client) SetLogLevel(levelStr string) error {
	level, err := logrus.ParseLevel(levelStr)
	if err != nil {
		return fmt.Errorf("parse log level: %w", err)
	}

	logrus.SetLevel(level)

	c.mu.Lock()
	connect := c.connect
	c.mu.Unlock()

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Ensure you call GetLatestSyncResponse only after a successful Start, which is what enables persistence for the embedded client.
  2. If the wrapped error is a read/parse failure, remove or reset the DNS/state file at StatePath and restart the client to repopulate it.
  3. Handle a missing latest response gracefully: no sync has completed yet is a normal state, not a hard failure.
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := client.GetLatestSyncResponse(); err != nil {
    // safe to call only after Start returned nil; gate on your own started flag
}

Try / catch

resp, err := client.GetLatestSyncResponse()
if err != nil {
    if strings.Contains(err.Error(), "persistence is disabled") {
        // called on an engine where persistence was never enabled: not retried away
    }
    // treat as no-sync-yet and continue degraded
}

Prevention

When it happens

Trigger: Calling GetLatestSyncResponse on an engine whose persistence was disabled (e.g. paths through internal clients that never enable it), or when the persisted sync state file is corrupt/unreadable. Note the embed Start also requires a successful sync before the engine reports up, so an empty-but-valid store is normal early.

Common situations: Persisted state directory deleted or corrupted mid-run (StatePath on ephemeral storage); a code path that uses the engine before Start completed its first sync; disk full at the time the state was written.

Related errors


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