Skip to content

Treat a path mismatch in DeleteWithXattrs like a missing xattr - #103

Merged
bbrks merged 1 commit into
mainfrom
delete-with-xattrs-path-mismatch
Oct 9, 2026
Merged

bbrks merged 1 commit into
mainfrom
delete-with-xattrs-path-mismatch

Conversation

@torcolvin

@torcolvin torcolvin commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

DeleteWithXattrs now handles a path through a scalar xattr value in the same way as a missing xattr, which matches Couchbase Server.

Document

key:    doc1
body:   {"foo":"bar"}
xattrs: _sync   = "scalar"
        _xattr1 = {"seq":1}   (some cases only)

The path _sync.rev goes through _sync, which is a string and not a JSON object.

Code

err := coll.DeleteWithXattrs(ctx, "doc1", []string{"_sync.rev"})
// or, with a present xattr:
err := coll.DeleteWithXattrs(ctx, "doc1", []string{"_sync.rev", "_xattr1"})

Results

Document state Paths Old result Expected result (Couchbase Server)
Live _sync.rev ErrPathMismatch. Body and xattrs unchanged. No error. Body deleted. Xattrs unchanged.
Live _sync.rev, _xattr1 ErrPathMismatch. Body and xattrs unchanged. No error. Body deleted. Xattrs unchanged.
Tombstone _sync.rev ErrPathMismatch. Xattrs unchanged. MissingError. Xattrs unchanged.
Tombstone _sync.rev, _xattr1 ErrPathMismatch. Xattrs unchanged. ErrPathMismatch. Xattrs unchanged.

A failed path makes the xattr part of the delete fail. On a live document, the body delete still happens. If every path fails on a tombstone, the error is MissingError. Otherwise, it is the error for the first failed path.

TestDeleteWithXattrsPathMismatch covers each row. If a tombstone has only some of the xattrs, TestDeleteWithXattrsMissingXattr now expects ErrPathNotFound.

🤖 Generated with Claude Code

Like Couchbase Server, a path through a scalar xattr value fails the combined
delete in the same way as a missing xattr. On a live document, only the body is
deleted. On a tombstone, the error is ErrPathMismatch, or not found when every
path fails.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the described semantics and is adequately covered by focused tests.

0 open findings

What changed in this PR

Aligns DeleteWithXattrs path-mismatch behavior with Couchbase Server.

Changes:

  • Preflights xattr paths and distinguishes missing paths from path mismatches.
  • Expands tests for live documents and tombstones.
File Description
collection+xattrs.go Implements failed-path detection and error handling.
collection_test.go Verifies missing and mismatched xattr behavior.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@torcolvin
torcolvin requested a review from bbrks October 9, 2026 01:42
@torcolvin
torcolvin marked this pull request as ready for review October 9, 2026 01:42
torcolvin added a commit to couchbase/sync_gateway that referenced this pull request Oct 9, 2026
…d events

Update rosmar to couchbaselabs/rosmar#103, which treats a path through a scalar
xattr in DeleteWithXattrs like a missing xattr, as Couchbase Server does. Add
the matching DeleteWithXattrsPathMismatch subtest.

TestXattrOnlyWriteKeepsTombstone now checks that the DCP feed reports each
xattr-only write to a tombstone as a deletion.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@bbrks
bbrks merged commit 27bd760 into main Oct 9, 2026
13 checks passed
@bbrks
bbrks deleted the delete-with-xattrs-path-mismatch branch October 9, 2026 15:43
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.

3 participants