cherry-pick of tag sync job fixes: empty bucket read - #170
Conversation
The shared Cassandra query helper drops read errors, so a failed read looked like an empty result. Tag sync aborted the whole run with cassandra_suspect_empty_bucket when a bucket listed in TagBucketMetadata read as empty, and other failed reads silently skipped tags or buckets. Tagging reads now go through queryRows, which returns read errors. A failed read aborts the sync with cassandra_error and the driver message; a bucket that really is empty is skipped, counted in emptyBuckets and logged. Tag API reads return an error instead of partial or empty results when Cassandra fails.
…rror handling and code clarity
GET /taggingService/tags/sync/status/{runId} returns one run record, so a
caller can poll a run without reading the whole history. 404 when the id is
not in the retained history; store errors are sanitized like /sync/status.
A failed read stored "cassandra_error: <driver error>" as the abort reason, which the status endpoints return to clients; driver errors can name hosts and keyspaces. The reason is now just cassandra_error and the driver error is logged under the run's audit_id.
queryRows now returns read errors instead of dropping them, and the tag APIs write errors into the response body, so a Cassandra outage could expose hosts and keyspaces. queryRows now logs the driver error with the query text and returns a generic "tag store read failed" error.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Some member-read paths still convert Cassandra failures into 404 or incomplete successful responses.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Improves tag-sync reliability by distinguishing Cassandra failures from genuinely empty buckets and adds per-run status polling.
Changes:
- Propagates and sanitizes Cassandra read errors.
- Skips and counts stale empty buckets.
- Adds a run-specific status endpoint and documentation.
| File | Description |
|---|---|
taggingapi/tag/tag_sync.go |
Handles empty buckets and sanitized abort reasons. |
taggingapi/tag/tag_sync_test.go |
Tests error handling and empty buckets. |
taggingapi/tag/tag_sync_state.go |
Uses error-aware state reads. |
taggingapi/tag/tag_sync_handler.go |
Adds sanitized status-loading and run lookup. |
taggingapi/tag/tag_sync_handler_test.go |
Tests missing run IDs. |
taggingapi/tag/tag_member_service.go |
Adopts error-aware tag-store reads. |
taggingapi/tag/query_rows.go |
Implements error-aware Cassandra queries. |
taggingapi/tag/query_rows_test.go |
Tests read-error sanitization. |
taggingapi/router.go |
Registers run-specific status route. |
contrib/docs/tagging_service_API_documentation.md |
Documents status and empty-bucket behavior. |
common/const_var.go |
Defines the run ID route key. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
coolwater
left a comment
There was a problem hiding this comment.
Approved. ✅
Reviewed the changes and did not find any blocking issues. The update improves tag sync resilience by correctly distinguishing stale/empty buckets from Cassandra read failures, adds good coverage around run status retrieval and error sanitization, and supports safer operational use of tag refresh workflows. The logic and tests look consistent with the intended behavior.

No description provided.