Skip to content

fix: persist contentHash on append and normalize response casing#16

Merged
dsghi merged 2 commits intomainfrom
devbrain-fix-hash-and-casing
Apr 13, 2026
Merged

fix: persist contentHash on append and normalize response casing#16
dsghi merged 2 commits intomainfrom
devbrain-fix-hash-and-casing

Conversation

@dsghi
Copy link
Copy Markdown
Contributor

@dsghi dsghi commented Apr 13, 2026

Summary

  • Bug 1: AppendAsync mutation path (append-to-existing) now computes ContentHash and ContentLength on the merged document before ReplaceItemAsync. Previously these fields were dropped, breaking CompareDocument for any appended-to document.
  • Bug 2: All anonymous-object response serializations use explicit lowercase property names (key = saved.Key) so System.Text.Json emits camelCase matching BrainDocument's [JsonPropertyName] attributes. contentHash added to AppendDocument and UpsertDocumentChunked responses.
  • Also fixed the same PascalCase issue in GetDocumentMetadata, ListDocuments, and SearchDocuments for consistency.

Test plan

  • AppendDocument to a new key → GetDocument returns contentHash + contentLength
  • AppendDocument to the same key again → GetDocument still returns correct contentHash + contentLength
  • CompareDocument against an appended-to doc with matching content → match: true
  • Verify AppendDocument response body uses camelCase and includes contentHash
  • Verify UpsertDocumentChunked finalize response uses camelCase and includes contentHash
  • Verify ListDocuments, SearchDocuments, GetDocumentMetadata responses use camelCase

🤖 Generated with Claude Code

dsghi and others added 2 commits April 12, 2026 17:56
… casing

AppendAsync's mutation path (ReplaceItemAsync) was writing the merged
document without recomputing ContentHash/ContentLength, causing those
fields to disappear from Cosmos after any second-or-later append. This
broke CompareDocument for any document that had been appended to.

All anonymous-object response serializations now use explicit lowercase
property names so System.Text.Json emits camelCase matching the
BrainDocument model's [JsonPropertyName] attributes. Also adds
contentHash to AppendDocument and UpsertDocumentChunked responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dsghi dsghi merged commit 17c452b into main Apr 13, 2026
4 checks passed
@dsghi dsghi deleted the devbrain-fix-hash-and-casing branch April 15, 2026 04:27
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