thedotmack/claude-mem · error
cloud sync identity unavailable; refusing an unreplicated…
Error message
cloud sync identity unavailable; refusing an unreplicated delete
What it means
deleteSyncedContent refuses to delete observations/summaries/prompts when cloud sync is configured but the device has no sync identity (no deviceId). Deleting such rows would create unreplicated deletes that strand replicas, so the route returns 503 instead.
Solutions
- Complete cloud sync setup/registration so the device obtains a deviceId, then retry the delete
- Check the sync status endpoint/logs to see why identity registration failed (auth token, network, server reachability)
- Re-run the initial sync or re-pair the device with the sync server
- As a last resort, disable cloud sync for this store if you accept the delete being unreplicated
Example fix
// before
deleteSyncedContent(...) // 503: no deviceId
// after
await cloudSync.register(); // obtain deviceId
if (cloudSync.status().deviceId) {
deleteSyncedContent(store, kind, table, originLocalId);
} Defensive patterns
Strategy: retry
Validate before calling
const status = await getCloudSyncStatus();
if (status.configured && !status.deviceId) throw new Error('Sync identity not registered yet; complete initial sync before deleting synced content'); Type guard
function hasSyncIdentity(s: { configured: boolean; deviceId?: string | null }): s is { configured: true; deviceId: string } {
return s.configured && typeof s.deviceId === 'string' && s.deviceId.length > 0;
} Try / catch
const res = await fetch(`/api/observations/${id}`, { method: 'DELETE' });
if (res.status === 503) {
// identity unavailable: schedule retry after sync registration completes
await waitForSyncIdentity();
return deleteObservation(id);
} Prevention
- Complete cloud-sync registration during onboarding before exposing delete actions
- Disable delete UI while sync identity is absent
- Monitor sync status and alert when deviceId is missing for an extended period
- Never bypass the guard by writing raw DELETE SQL against synced tables
When it happens
Trigger: DELETE /api/observations/:id, /api/summaries/:id, or /api/prompts/:id while cloudSync.isConfigured() is true but cloudSync.status().deviceId is null/undefined — i.e. sync is set up but the device has never completed identity registration.
Common situations: Cloud sync credentials configured but initial sync/registration never ran or failed; device record removed server-side; sync service temporarily unable to report its identity; fresh install with imported settings but no first sync.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- cloud sync unavailable; refusing an unreplicated delete
- pull
- push
- sync hub pull: malformed /changes response
- sync hub pull: more must be boolean
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/71f577c2f556a7b4.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker/http/routes/DataRoutes.ts:362
this.badRequest(res, 'id must be a positive canonical decimal string');
return;
}
const store = this.dbManager.getSessionStore();
const row = store.db.prepare(`
SELECT CAST(id AS TEXT) AS id FROM ${table}
WHERE id = ? AND origin_device_id IS NULL
`).get(originLocalId) as { id: string } | undefined;
if (!row) {
this.notFound(res, `${kind} #${originLocalId} not found`);
return;
}
const cloudSync = this.dbManager.getCloudSync();
let entityRev: string | null = null;
if (cloudSync?.isConfigured()) {
if (!cloudSync.status().deviceId) {
res.status(503).json({ error: 'cloud sync identity unavailable; refusing an unreplicated delete' });
return;
}
entityRev = cloudSync.queueDelete(kind, originLocalId);
} else {
// A row with an acknowledged entity head must never be silently deleted
// while its sync identity is unavailable: that would strand replicas.
const acknowledged = store.db.prepare(`
SELECT 1 AS found FROM sync_entity_heads
WHERE kind = ? AND origin_local_id = ? LIMIT 1
`).get(kind, originLocalId) as { found: number } | undefined;
if (acknowledged) {
res.status(503).json({ error: 'cloud sync unavailable; refusing an unreplicated delete' });
return;
}
store.db.prepare(
`DELETE FROM ${table} WHERE id = ? AND origin_device_id IS NULL`
).run(originLocalId);
}View on GitHub (pinned to d8bc9755e7)