You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: actionable error when API called before cloudsync_init (#47)
Six functions leaked misleading low-level symptoms when called before
any cloudsync_init('<table_name>'):
cloudsync_changes -> "out of memory (7)"
cloudsync_db_version -> "Unable to retrieve db_version (not an error)"
cloudsync_db_version_next -> same pattern (SQLite) / silent -1 (PG)
cloudsync_set_filter -> 10+ "no such table" NOTICEs + generic trigger error
cloudsync_clear_filter -> same as set_filter
cloudsync_payload_apply -> 3x "no such table: cloudsync_settings" debug lines
followed by "Runtime error: not an error"
Add cloudsync_context_is_initialized() helper and guard each function
on its error branch. When the root cause is missing init, raise a
single message pointing at SELECT cloudsync_init('<table_name>').
The guard is a NULL-pointer check on the error branch only, so the
sync hot path (cloudsync_db_version_next stepped by merge triggers on
every received row, cloudsync_payload_apply on every inbound sync) is
unaffected.
cloudsync_changes on PostgreSQL was already graceful (empty result
set), so no fix was needed there.
Regression test in test/unit.c matches the stable substring
"cloudsync_init" rather than full text, so future rewordings do not
break it.
Bumps to 1.0.17.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
7
+
## [1.0.17] - 2026-04-24
8
+
9
+
### Fixed
10
+
11
+
-**Confusing errors when `cloudsync_init` was never called**: `cloudsync_changes` (SQLite), `cloudsync_db_version`, `cloudsync_db_version_next`, `cloudsync_set_filter`, `cloudsync_clear_filter`, and `cloudsync_payload_apply` now raise a single actionable message pointing at `SELECT cloudsync_init('<table_name>')` instead of leaking low-level symptoms (`out of memory`, `not an error`, silent `-1`, multi-line "no such table" dumps). The guard runs only on the error branch, so the sync hot path is unaffected.
errmsg("cloudsync is not initialized: call SELECT cloudsync_init('<table_name>') to enable sync on a table before calling cloudsync_db_version_next().")));
276
+
}
277
+
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
278
+
errmsg("Unable to retrieve next_db_version (%s)", database_errmsg(data))));
279
+
}
259
280
}
260
281
PG_CATCH();
261
282
{
@@ -670,6 +691,16 @@ Datum cloudsync_set_filter (PG_FUNCTION_ARGS) {
670
691
671
692
PG_TRY();
672
693
{
694
+
// Guard against calling set_filter before the target table has been
695
+
// set up for sync: without this, we'd drop and fail to recreate
696
+
// triggers, emitting ten+ noisy "does not exist, skipping" NOTICEs
697
+
// followed by a generic "error recreating triggers" message that
698
+
// does not point at the real cause.
699
+
if (!cloudsync_context_is_initialized(data) || !table_lookup(data, tbl)) {
0 commit comments