Skip to content

fix(config): a false boolean is a value, not a missing key (#159) - #165

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/159-ndc-compression-flag
Jul 26, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/159-ndc-compression-flag

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #159.

The filed issue was that save-session.sh never consulted features.ndc_compression. It does now — but that alone would have fixed nothing, because the flag could not be read.

config() could not read false

jq '.features.ndc_compression // empty'  ->  []     # the value is false
jq '.features.recovery // empty'         ->  []     # the value is false

jq's // treats false exactly like null, so every option explicitly set to false came back as its default. Two shipped, documented options default to true and were therefore impossible to switch off: features.ndc_compression and features.recovery. The second has been broken just as long, unreported.

config() now maps a genuinely absent key to empty inside jq, and returns everything else.

Two near misses, both found by review

Testing the printed value against "null" looks equivalent and is not: jq -r prints the same bare word for JSON null and for the string "null", so that version silently discarded a legitimate value. reject_pattern is the only plausible place someone would hit it, but a user-set value being ignored is the same class as the bug in hand.

Verified across false, 0, "", "null", explicit null, absent keys, absent paths, and a path traversing a scalar (jq errors, stdout empty, falls back).

Review also enumerated every config call site — 20 of them across the hooks and scripts — checking whether any relied on the old collapsing behaviour. None do. Numeric options were never affected (// intercepts null and false, not 0), and git_backup.gpg_sign/allow_remote_change worked only by coincidence, their default happening to equal the collapse target.

The tell was in the test suite

The shared harness has been setting ndc_compression: false for months, and six compression tests were relying on that option not working. They broke the moment the flag became real. The harness now says true, which is the shipped default and what those tests always meant.

That is also how the bug surfaced at all: while testing #136 I had to defeat compression by hand, because the documented switch did nothing.

680 passing.

Florian DAVID added 2 commits July 26, 2026 04:04
config() asked jq for `$key // empty`. jq's // treats false exactly like
null, so every option explicitly set to false read back as its default —
and the two shipped options that default to true, features.ndc_compression
and features.recovery, both documented, could never be switched off.

The filed issue was the narrower symptom: save-session.sh never consulted
the compression flag at all. It does now, but the flag would still have
been unreadable without fixing config(), and features.recovery was broken
the same way with nobody having noticed.

config() asks for the value and treats only null — a genuinely absent key
— as missing. Verified false, 0, normal values, absent keys and absent
paths all read correctly.

Six existing tests failed when the flag started working: the shared
harness sets ndc_compression false, so every test that exercises
compression was relying on the option not working. The harness now says
true, which is the shipped default and what those tests always meant.

Co-Authored-By: Max <noreply>
Review found my own fix swallowing a value: `jq -r` prints the bare word
null for a JSON null AND for the string "null", so testing the printed
result against "null" discarded a legitimate config value. Narrow —
reject_pattern is the only plausible place — but it is a value the user
set being ignored, which is the same class as the bug being fixed.

The null test moves inside jq, where the two are different things, and
tostring handles the rest. Verified across false, 0, "", "null", explicit
null, absent keys, absent paths and a path traversing a scalar.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit d9480ec into main Jul 26, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/159-ndc-compression-flag branch July 26, 2026 02:23
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.

features.ndc_compression is documented but read nowhere — setting it false does nothing

1 participant