Skip to content

fix: handle integer JSON values in server mode parseFloat#167

Merged
dmtrKovalenko merged 1 commit into
dmtrKovalenko:mainfrom
NicoHinderling:fix/server-parse-integer-as-float
Apr 7, 2026
Merged

fix: handle integer JSON values in server mode parseFloat#167
dmtrKovalenko merged 1 commit into
dmtrKovalenko:mainfrom
NicoHinderling:fix/server-parse-integer-as-float

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

Fixes #166

Summary

  • parseFloat in server mode only matched .float JSON values, causing integer values like {"threshold": 0} to silently fall back to the default (0.1)
  • Added .integer branch to parseFloat, matching the pattern already used in parseDiffOverlay
  • Added a test that verifies "threshold": 0 (integer) detects diffs correctly in server mode

Context

Zig's std.json parser distinguishes between 0 (.integer) and 0.0 (.float). Since the JSON spec doesn't distinguish these, callers reasonably send "threshold": 0 and expect it to work — but it was silently ignored.

The CLI path (--threshold 0) is unaffected since it parses the string argument directly.

The `parseFloat` helper only checked for `.float` JSON values, causing
integer values like `{"threshold": 0}` to silently fall back to the
default (0.1). This is because zig's std.json parser distinguishes
between `0` (integer) and `0.0` (float).

This made `threshold: 0` behave as `threshold: 0.1` in server mode,
while the CLI `--threshold 0` worked correctly.

The fix adds an `.integer` branch matching the pattern already used
in `parseDiffOverlay`.
@dmtrKovalenko dmtrKovalenko merged commit 133eebd into dmtrKovalenko:main Apr 7, 2026
11 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.

Server mode: 0 integer threshold values silently fall back to default

2 participants