feat(network): support cloudsync failures.{apply,check} response shape#48
Merged
feat(network): support cloudsync failures.{apply,check} response shape#48
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lastFailureextraction from cloudsync'sSyncStatusResponsewith the new per-stagefailures.{apply, check}shape.send.lastFailureis now sourced fromfailures.apply; a new optionalreceive.lastFailuresurfacesfailures.check(e.g.encode_changesjob 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./checkresponse: HTTP 200 still returns{url}(artifact ready); HTTP 202 now returns the fullSyncStatusResponsesnapshot. The C side branches on the presence ofurland opportunistically extractsfailures.checkfrom either shape. Removes the obsolete "missing 'url' is an error" branch that would have broken against the new server.test_failure_path) that targets a cloudsync database configured to fail apply and check jobs, assertinglastFailuresurfaces on the second invocation of all three SQL functions. WiresINTEGRATION_TEST_FAILURE_DATABASE_IDthrough.github/workflows/main.yml. Skips gracefully when the env var is unset.Bumps
CLOUDSYNC_VERSIONto1.0.18. Doc updates inAPI.mdcover the error-handling table and all three function sections (schema, scoping rules, examples).CHANGELOG.mdentry under[1.0.18].The wire-format SQL field name
send.lastFailureis preserved — only its server-side source changed (lastFailure→failures.apply). Existing consumers ofsend.lastFailurekeep working.Test plan
make clean && make && make unittest— all SQLite unit tests pass.make postgres-docker-run-testagainst standalone PG (port 5432) — full suite passes.make postgres-supabase-run-testagainst supabase (port 54322) — full suite passes.make e2efailure-path integration test against a server-side configured failure DB —send.lastFailure,receive.lastFailure, andcloudsync_network_syncall emitlastFailureon thesecond invocation.
INTEGRATION_TEST_FAILURE_DATABASE_IDsecret provisioned.{"send":{...},"receive":{...}}with no spuriouslastFailurekeys.