Repository navigation
Fail on a new required field that old rows would decode as zero - #4
Merged
Merged
Conversation
The generated decoder guards only nullable fields with hasX(), so a required field a row never wrote takes its zero value: a @default(true) bool becomes false, an enum its first value. The proto's history has 34 such additions in 28 commits, and nothing looked at them. The ledger now records messages and required fields. A new required field on a known message fails until it names a decoder, or says under "zero_value_ok" why the zero value is right. A rename that drops optional is one of these, as old rows hold the old number. A field on a new message passes, as no old row has it. --update records only what cannot lose data, so it cannot hide either edit. On a ledger with no messages it records everything, once. Replaying the 28 commits finds exactly those 34 fields and the real Invoice.due_date drop. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
LabellingInfo and the like are stored inside Operation, so _decodeOperationCompat is on ProtoEntityConverter<Operation>. Requiring the field's own converter would reject that correct pattern. It now passes if the decoder's body names the message, and an unrelated decoder still fails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
Replaying real edits showed oneof arms counted as required, so every new OperationInfo arm failed with no valid way through. They are now neither. Renaming a message passed through --update, though its rows remain, so a message that disappears now fails until it is deleted from the ledger by hand. A removed required field is dropped by --update, so adding it back counts as new. A damaged ledger could wipe the record through --update. Parsing now refuses a missing section, and accepting the proto as it is takes an explicit --init that refuses a ledger with messages. Every compat entry is validated, and an empty reason no longer counts. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generated decoder guards only nullable fields with
hasX(), so a required field a row never wrote takes its zero value. The proto history has 34 such additions in 28 commits, and nothing looked at them.compat, or says why the zero value is right underzero_value_ok. A rename counts, as old rows hold the old number. A field on a new message passes, andoneofarms are not counted._decodeOperationCompatdoes forLabellingInfo.--updaterecords only what cannot lose data. A message that disappears fails until it is deleted from the ledger by hand, as renaming one keeps its rows.--init, which refuses a ledger that has messages.Testing
./check.shpasses: 56 tests incb_lints, 62 incb_checks.Invoice.due_datedrop, with no other output.cb-mobile's proto, ledger and converters:--initpasses at 939 optional and 862 required fields. A new required field and a renamed message fail, and--updateleaves them failing. A newOperationInfoarm passes. A ledger missingmessagesis refused.An independent review found the
oneof, rename, damaged-ledger and validation problems fixed here. These fixes have not been reviewed again.Not covered
@Defaultfields at the source would be stronger: emit them asoptionaland decodehasX() ? x : <default>.model_spec.dartalready recordshasDefault.After merging: tag
v1.3.0, then incb-mobilemove both pins, run--initonce, and updateCLAUDE.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2