Priority order
Order: 05 of 09
Priority: P2 correctness
Problem
Provider error handling and binary materialization have fragile edge cases.
Evidence:
src/NEventStore.Persistence.Sql/SqlDialects/MySqlDialect.cs:43
- MySQL duplicate detection reflects a
Number property and immediately casts it.
src/NEventStore.Persistence.Sql/CommitExtensions.cs:87
GetByteArray returns [default] for null/DBNull.Value.
Impact
- MySQL can mask non-provider exceptions with
NullReferenceException or invalid casts during error handling.
- Nullable
Headers values can be deserialized from one zero byte instead of returning default, which can fail for legacy rows or manually inserted rows.
Mandatory test-first workflow
- Add tests first to reproduce or verify each behavior.
- Add a unit test proving
MySqlDialect.IsDuplicate(new Exception(...)) returns false and does not throw.
- Add a materialization test for a commit row with
Headers = NULL.
- Do not change production code until the tests capture the expected behavior.
Proposed action
- Guard MySQL
IsDuplicate for missing or non-int Number.
- Prefer provider-specific exception checks where available.
- Return
[] for null and DBNull.Value in GetByteArray.
Acceptance criteria
- Duplicate detection does not throw for unrelated exception types.
- Null headers materialize as default/empty headers behavior without deserialization failure.
- Existing duplicate-commit behavior remains covered.
Source: docs/Project-Analysis-Issue-Drafts.md.
Priority order
Order: 05 of 09
Priority: P2 correctness
Problem
Provider error handling and binary materialization have fragile edge cases.
Evidence:
src/NEventStore.Persistence.Sql/SqlDialects/MySqlDialect.cs:43Numberproperty and immediately casts it.src/NEventStore.Persistence.Sql/CommitExtensions.cs:87GetByteArrayreturns[default]fornull/DBNull.Value.Impact
NullReferenceExceptionor invalid casts during error handling.Headersvalues can be deserialized from one zero byte instead of returning default, which can fail for legacy rows or manually inserted rows.Mandatory test-first workflow
MySqlDialect.IsDuplicate(new Exception(...))returns false and does not throw.Headers = NULL.Proposed action
IsDuplicatefor missing or non-intNumber.[]fornullandDBNull.ValueinGetByteArray.Acceptance criteria
Source:
docs/Project-Analysis-Issue-Drafts.md.