CHAINS-0 envconfig: trim whitespace around map keys/values in reflect path - #2
Open
paxos-hoplites-agent[bot] wants to merge 1 commit into
Open
paxos-hoplites-agent[bot] wants to merge 1 commit into
paxos-hoplites-agent[bot] wants to merge 1 commit into
Conversation
Plain map[K]V envconfig fields go through the reflection path in
processField, which splits on "," and ":" with no TrimSpace. YAML folded
block scalars (>-) fold newlines into spaces, so a multi-line map value
such as:
CHAINS_ENABLED: >-
NETWORK_ETH:true,
NETWORK_BTC:true
arrives as "NETWORK_ETH:true, NETWORK_BTC:true" — with a leading space
before NETWORK_BTC. Without trimming, " NETWORK_BTC" becomes a distinct
key and lookups for the intended key silently miss.
Fields backed by a custom Decode() method were already safe because
their decoders trim; this brings plain-map fields to parity by trimming
both key and value in the reflect.Map path, covering every map field at
once rather than requiring per-field typed aliases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Nick Geib <nicholas.geib@paxos.com>
paxos-hoplites-agent
Bot
force-pushed
the
hoplites/nickg/aW9qdJ7y-trim-map-whitespace
branch
from
July 17, 2026 23:53
3ff581f to
7dcfca2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plain
map[K]Venvconfig fields go through the reflection path inprocessField, which splits on,and:with nostrings.TrimSpace. YAML folded block scalars (>-) fold newlines into spaces, so a multi-line map value such as:arrives as
NETWORK_ETH:true, NETWORK_BTC:true— with a leading space beforeNETWORK_BTC. Without trimming," NETWORK_BTC"becomes a distinct key and lookups for the intended key silently miss (e.g. recon quietly stops running for that chain).Fields backed by a custom
Decode()method were already safe because their decoders trim. This brings plain-map fields to parity by trimming both the key and the value in thereflect.Mappath — fixing every map field at once rather than requiring per-field typed aliases in each consumer.Context: paxosglobal/pax#60519 (comment).
Changes
envconfig.go— trim whitespace around the key and value when decoding map entries in the reflection pathenvconfig_test.go—TestMapFieldWhitespaceTrimmedcovering space-after-comma (the YAML>-case), space around the colon, and leading/trailing whitespace