Skip to content

Fix #2190: avoid duplicate id element enumeration#2758

Open
JKamsker wants to merge 2 commits into
litedb-org:devfrom
JKamsker:bug/2190-id-field-name-truncation
Open

Fix #2190: avoid duplicate id element enumeration#2758
JKamsker wants to merge 2 commits into
litedb-org:devfrom
JKamsker:bug/2190-id-field-name-truncation

Conversation

@JKamsker

Copy link
Copy Markdown
Collaborator

Fixes #2190.

Summary

  • Makes BsonDocument.GetElements() exclude _id using the same case-insensitive comparison as the backing dictionary.
  • Prevents case-variant _Id properties from being emitted twice during serialization.
  • Fixes debug-time buffer overflows and release-time field-name truncation such as Played becoming Pla.

TDD / verification

  • Added Issue2190 coverage for the raw BsonDocument.GetElements() duplicate element bug.
  • Added end-to-end typed insert coverage for an entity with _Id and Played properties.
  • Verified targeted issue tests, document tests, buffer-writer tests, and the full net8.0 test project.

Compatibility note

No valid on-disk format is changed. The affected documents either failed to serialize in debug builds or could be written corrupted in release builds; this prevents new corruption.

JKamsker and others added 2 commits June 10, 2026 22:33
Add Issue2190 coverage for a typed entity with an _Id property and non-nullable Played field. The tests capture the duplicate _id element enumeration that undersizes the BSON buffer and causes the reported field-name truncation or debug-time insert failure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make BsonDocument.GetElements exclude _id using the same case-insensitive comparison as the backing dictionary. This prevents _Id properties from being emitted twice, which undersized BSON buffers and could truncate following field names during insert.

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

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2a4d330-17c1-46e0-ae0f-52290b9dced7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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