refactor: add type-safe BSON helpers in writer_security#6
refactor: add type-safe BSON helpers in writer_security#6retran wants to merge 1 commit intopr2-reader-migrationfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors sdk/mpr/writer_security.go to centralize BSON primitive type extraction into small helpers, eliminating silent comma-ok assertions and panic-prone type assertions while adding diagnostics for unexpected BSON value types.
Changes:
- Added
bsonString/bsonBoolhelpers to safely extract typed values from BSON fields with logging on type mismatches. - Replaced multiple silent
v, _ := ...assertions and bare.(type)assertions with helper calls across security-writer mutations/merges.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5e49429 to
b2c99ab
Compare
231606c to
fd6530f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b2c99ab to
dcf76c0
Compare
fd6530f to
a1e8dad
Compare
dcf76c0 to
0091e56
Compare
a1e8dad to
fd9950e
Compare
0091e56 to
a94b326
Compare
fd9950e to
778f837
Compare
a94b326 to
d7f88c1
Compare
778f837 to
6ef29ce
Compare
d7f88c1 to
1d67cb5
Compare
6ef29ce to
c4e3655
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
058d9e1 to
3b527e0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b527e0 to
fac524a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fac524a to
72a49c8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Superseded by upstream PR mendixlabs#297 |
Why
writer_security.gocontains ~26 type assertions on BSON interface values. Silent comma-ok patterns (v, _ = f.Value.(string)) swallow unexpected types and produce zero-value strings/bools that corrupt security data without any diagnostic. Bare assertions (ref = mf.Value.(string)) panic at runtime on type mismatches. Both patterns make debugging serialization issues extremely difficult. Centralizing these into typed helpers adds diagnostic logging and eliminates the entire class of silent-corruption and panic-crash bugs.Summary
bsonStringandbsonBoolhelper functions that extract typed values from BSON interface fields with diagnostic logging for unexpected typesv, _ = f.Value.(string)) and 6 bare panic-risk assertions (ref = mf.Value.(string)) with helper callswriter_security.go(bson.D/bson.Aassertions with properif !okguards left unchanged)Stacked on
Test
make build && make test && make lint-go— all pass