Skip to content

fix(conf): stop INI parser corrupting octal and 0/1 values#39

Merged
chyzwar merged 1 commit into
masterfrom
fix/conf-ini-value-coercion
Jun 2, 2026
Merged

fix(conf): stop INI parser corrupting octal and 0/1 values#39
chyzwar merged 1 commit into
masterfrom
fix/conf-ini-value-coercion

Conversation

@chyzwar
Copy link
Copy Markdown
Collaborator

@chyzwar chyzwar commented Jun 2, 2026

readValue coerced any numeric-looking string to a number and mapped 1/0 to booleans. UMask=0077 became 77 (then failed z.string()), and RestartSec=1 / OOMScoreAdjust=0 became booleans the numeric schemas rejected, so Service.fromINI threw on valid units.

Now coerce to a number only when String(n) === trimmed, and drop the 1/0->boolean branches. Octal/leading-zero/hex and infinity tokens stay strings for the Zod schema, which knows each field's real type.

readValue coerced any numeric-looking string to a number and mapped 1/0 to
booleans. UMask=0077 became 77 (then failed z.string()), and RestartSec=1 /
OOMScoreAdjust=0 became booleans the numeric schemas rejected, so
Service.fromINI threw on valid units.

Now coerce to a number only when String(n) === trimmed, and drop the
1/0->boolean branches. Octal/leading-zero/hex and infinity tokens stay strings
for the Zod schema, which knows each field's real type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chyzwar chyzwar merged commit 631918c into master Jun 2, 2026
1 check passed
@chyzwar chyzwar deleted the fix/conf-ini-value-coercion branch June 2, 2026 12:01
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.

1 participant