Skip to content

fix: parse errors and panics on edge-case values - #23

Merged
wrfly merged 1 commit into
masterfrom
fix/parse-edge-cases
Aug 15, 2026
Merged

fix: parse errors and panics on edge-case values#23
wrfly merged 1 commit into
masterfrom
fix/parse-edge-cases

Conversation

@wrfly

@wrfly wrfly commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Bug fixes for edge-case values that previously produced silent wrong values, errors, or panics:

  • int fields no longer accept duration syntax (e.g. 10s used to silently set the value to 1e10 nanoseconds); only time.Duration fields are parsed as durations
  • int/uint/float fields and pointers are parsed with their bit size, so out-of-range values error out instead of being silently truncated
  • []int64 with duration-like values and []time.Duration with plain numbers no longer panic in reflect.Value.Set
  • *[]T pointer-to-slice fields now parse correctly (previously failed with "field is not addressable")
  • environment values now overwrite non-nil pointer fields, matching the documented behavior
  • parseScientific rejects negative exponents (e.g. 1e-3 used to silently become 1) and handles comma+exponent combos like 1,000e3
  • Parse(&c) where c is already a pointer no longer panics; nil or non-struct configs return an error instead of panicking, List returns an empty list

All existing tests pass; 13 regression tests were added in bugfix_test.go.

- int fields no longer accept duration syntax (e.g. "10s" used to
  silently set the value to 1e10 nanoseconds); only time.Duration
  fields are parsed as durations
- int/uint/float fields and pointers are parsed with their bit size so
  out-of-range values error out instead of being silently truncated
- []int64 with duration-like values and []time.Duration with plain
  numbers no longer panic in reflect.Value.Set
- *[]T pointer-to-slice fields now parse correctly
- env values now overwrite non-nil pointer fields
- parseScientific rejects negative exponents instead of silently
  returning a wrong number, and handles comma+exponent combos
- Parse(&c) with c being a pointer no longer panics; nil or
  non-struct configs return an error, List returns an empty list
@wrfly
wrfly merged commit d14d831 into master Aug 15, 2026
1 check passed
@wrfly
wrfly deleted the fix/parse-edge-cases branch August 15, 2026 19:13
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