Skip to content

feat(network): support cloudsync failures.{apply,check} response shape#48

Merged
andinux merged 6 commits intomainfrom
feat/cloudsync-failures-response
Apr 29, 2026
Merged

feat(network): support cloudsync failures.{apply,check} response shape#48
andinux merged 6 commits intomainfrom
feat/cloudsync-failures-response

Conversation

@andinux
Copy link
Copy Markdown
Collaborator

@andinux andinux commented Apr 28, 2026

Summary

  • Replaces the single lastFailure extraction from cloudsync's SyncStatusResponse with the new per-stage failures.{apply, check} shape. send.lastFailure is now sourced from failures.apply; a new optional receive.lastFailure surfaces failures.check (e.g. encode_changes job failures). Per-function scoping is strict: cloudsync_network_send_changes() is send-scoped, cloudsync_network_check_changes() is check-scoped, cloudsync_network_sync() reports both.
  • Handles the new dual-shape /check response: HTTP 200 still returns {url} (artifact ready); HTTP 202 now returns the full SyncStatusResponse snapshot. The C side branches on the presence of url and opportunistically extracts failures.check from either shape. Removes the obsolete "missing 'url' is an error" branch that would have broken against the new server.
  • Adds an integration test (test_failure_path) that targets a cloudsync database configured to fail apply and check jobs, asserting lastFailure surfaces on the second invocation of all three SQL functions. Wires INTEGRATION_TEST_FAILURE_DATABASE_ID through .github/workflows/main.yml. Skips gracefully when the env var is unset.

Bumps CLOUDSYNC_VERSION to 1.0.18. Doc updates in API.md cover the error-handling table and all three function sections (schema, scoping rules, examples). CHANGELOG.md entry under [1.0.18].

The wire-format SQL field name send.lastFailure is preserved — only its server-side source changed (lastFailurefailures.apply). Existing consumers of send.lastFailure keep working.

Test plan

  • make clean && make && make unittest — all SQLite unit tests pass.
  • make postgres-docker-run-test against standalone PG (port 5432) — full suite passes.
  • make postgres-supabase-run-test against supabase (port 54322) — full suite passes.
  • make e2e failure-path integration test against a server-side configured failure DB — send.lastFailure, receive.lastFailure, and cloudsync_network_sync all emit lastFailure on the
    second invocation.
  • CI green on this branch with INTEGRATION_TEST_FAILURE_DATABASE_ID secret provisioned.
  • Manual smoke against a healthy database — happy path still emits {"send":{...},"receive":{...}} with no spurious lastFailure keys.

andinux and others added 6 commits April 27, 2026 16:53
Replaces the old single `lastFailure` extraction with per-stage
`failures.apply` / `failures.check`. `send.lastFailure` is now sourced
from `failures.apply`; a new `receive.lastFailure` surfaces
`failures.check`. Per-function scoping is strict: send_changes is
send/apply-scoped, check_changes is check-scoped, sync reports both.

Also handles the new dual-shape `/check` response: HTTP 200 with
`{url}` (artifact) vs HTTP 202 with the SyncStatusResponse snapshot
(no artifact yet). Previously the 202 path errored with
"missing 'url'" against the new server.

Bumps CLOUDSYNC_VERSION to 1.0.18 and updates API.md / CHANGELOG.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Targets a cloudsync database (INTEGRATION_TEST_FAILURE_DATABASE_ID)
configured server-side to fail apply and check jobs. After priming the
server with a payload and a check, asserts the second invocation of
cloudsync_network_send_changes, cloudsync_network_check_changes, and
cloudsync_network_sync surfaces lastFailure in the JSON output.

Skips when INTEGRATION_TEST_FAILURE_DATABASE_ID is not set so existing
CI runs continue to pass until the env var is provisioned.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wire the new secret through the env block, the alpine docker-exec
container, and the android emulator export so the failure-path
integration test runs in CI instead of skipping.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Advertise the extension version on every cloudsync HTTP call via
X-CloudSync-Version, and signal check-endpoint capabilities via
X-CloudSync-Capabilities: check-status-response so the server returns the
SyncStatusResponse body on HTTP 202. S3 pre-signed upload/download
requests are not annotated.

network_receive_buffer now takes a (const char **extra_headers, int
nextra_headers) array instead of two singular header parameters, with
two static call-site arrays (default and check). The legacy
"Accept: sqlc/plain" header is dropped, and the version line is now a
compile-time concatenation of the header name and CLOUDSYNC_VERSION
rather than an snprintf at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Describe the cloudsync_network_* changes in terms of what callers
observe (spurious 'missing url' error fixed, new receive.lastFailure
field for server-side receive failures) instead of internal wire-format
details about the upstream cloudsync HTTP service.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@andinux andinux merged commit 70b6639 into main Apr 29, 2026
28 checks passed
@andinux andinux deleted the feat/cloudsync-failures-response branch April 29, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant