Skip to content

Drop nil-valued keys from nREPL requests - #4186

Merged
bbatsov merged 1 commit into
masterfrom
strip-nil-request-values
Sep 20, 2026
Merged

bbatsov merged 1 commit into
masterfrom
strip-nil-request-values

Conversation

@bbatsov

@bbatsov bbatsov commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

A nil value in a request dict was bencoded as an empty list, which nREPL treats as an explicit false for some keys and as garbage for the rest. The encoder now leaves nil-valued entries out at any depth, and vectors encode as bencode lists so [] remains available when an empty list is really meant (the pr request uses it for stream?).

Fixes #2854
Closes #2362

@bbatsov
bbatsov force-pushed the strip-nil-request-values branch 2 times, most recently from ade61a2 to 50ac40d Compare September 10, 2026 08:42
Bencode has no nil, so a nil value in a request dict went out as an
empty list. nREPL reads that as an explicit false for a couple of keys
and as junk for the rest, so a caller that meant "not set" could end up
binding *print-length* to [] or asking the printer for a [] margin.

Drop nil-valued entries in the bencode dict encoder itself, so nested
dicts (print options, queries, log filters) get the same treatment as
the top-level request and every sender benefits without a wrapper. To
keep a way to send an empty list on purpose, vectors now encode as
bencode lists; the pr request plist uses [] for stream?, which is how
nREPL spells "off" for that key. Settles the nil-vs-empty-list debate in
#2362 as well.
@bbatsov
bbatsov force-pushed the strip-nil-request-values branch from 50ac40d to 538bfa1 Compare September 15, 2026 10:35
@bbatsov
bbatsov merged commit 47031b0 into master Sep 20, 2026
17 checks passed
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.

[nrepl-client] Automatically disjoin false/nil keys from requests Figure out how to encode nil and an empty list differently

1 participant