Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] LiteDB Opens Non-Database Files and Throws Exception on Large Invalid Content #2501

Open
PanWuming opened this issue Jun 9, 2024 · 1 comment
Labels

Comments

@PanWuming
Copy link

Description

LiteDB can open non-database files as if they were database files. When the content of a text file is just "Invalid content," LiteDB will open it as a normal database file and write data to it. However, if the "Invalid content" is repeated many times, making the file size reach 16K, LiteDB will throw an unhandled exception when writing data.

Steps to Reproduce

  1. Create a text file with the content "Invalid content."
  2. Attempt to open the file with LiteDB and write data to it. Notice that LiteDB treats it as a valid database file.
  3. Modify the text file by repeating "Invalid content" until the file size reaches 16K.
  4. Attempt to write data to the file using LiteDB. An unhandled exception will be thrown.

Expected Behavior

LiteDB should not treat non-database files as valid database files. It should properly validate the file content and structure before opening and writing data. If the file content is invalid, LiteDB should throw an appropriate exception indicating the issue.

Environment

  • LiteDB version: [5.0.20]
  • Operating system: [Mac OS 13.6.3 (22G436)]
  • .NET runtime: [Net8.0]
@JKamsker
Copy link
Collaborator

Could you please write an unit test in a pr for that and reference it here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants