fix(startup): reject malformed environment config (EN-1922) - #1847
Open
gfyrag wants to merge 2 commits into
Open
fix(startup): reject malformed environment config (EN-1922)#1847gfyrag wants to merge 2 commits into
gfyrag wants to merge 2 commits into
Conversation
Contributor
✅ Approve — automated reviewThe dependency update, documentation, and subprocess regression test consistently enforce malformed environment configuration failure before startup. No actionable correctness issues were found. No findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v3.0 #1847 +/- ##
================================================
+ Coverage 76.90% 77.04% +0.14%
================================================
Files 472 472
Lines 50453 50453
================================================
+ Hits 38800 38874 +74
+ Misses 8252 8177 -75
- Partials 3401 3402 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Azorlogh
previously approved these changes
Aug 31, 2026
gfyrag
force-pushed
the
fix/en-1922-malformed-env
branch
from
September 1, 2026 09:06
b68bcab to
f8c649f
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.
Traceability
Before fix
At target base
23b4f498138b3ca222b52533fb683830fac38149, the production binary was started withGRPC_PORT=not-an-integerand otherwise valid bootstrap, bind, HTTP, WAL, and data arguments. The process remained running, reported effectivegrpcport: 0, opened gRPC on an ephemeral port and HTTP on the requested port, and later exited 0 after SIGTERM. The typed pflag setter had mutated the value to zero before returning its discarded parse error. A second production run withGRPC_COMPRESSION=not-a-boolpreserved the valid defaultfalseand also reached running state.BEFORE_FIX=BUG_REPRODUCED
Root cause and ownership
service.Executeuses the shared go-libs environment binder. That binder discarded errors returned by typedpflag.Set, allowing malformed selected environment configuration to continue. This shared primitive is the correct ownership boundary, so the implementation is in formancehq/go-libs#673. This PR is the minimal Ledger dependency update plus a production-boundary regression and deployment contract.FIX_OWNERSHIP=GO_LIBS
Precedence contract
Configuration precedence remains explicit CLI flag, then environment, then default. A malformed environment value selected by that precedence fails. A valid explicit CLI value for the same flag wins and causes the malformed lower-precedence environment value to be ignored. This was verified with a real process: malformed
GRPC_PORTplus--grpc-port 56735started on 56735 with no environment error.Fix and after-fix evidence
The pinned go-libs candidate propagates typed parse errors with environment and flag context while preserving early binding for command initialization and deferring selected-value failure until after Cobra parses explicit flags. The Ledger regression exercises
server.NewRootCommandthroughservice.Executein a subprocess.With the candidate binary and
GRPC_PORT=not-an-integer, startup exited 1 with:binding environment variable GRPC_PORT to flag --grpc-port: invalid argument "not-an-integer" for "--grpc-port" flag: strconv.ParseInt: parsing "not-an-integer": invalid syntaxNo WAL or data directory was created and no application or gRPC startup marker appeared.
AFTER_FIX=PASS
Regression sensitivity
The shared binder was temporarily mutated to discard the parse error again. The Ledger process-boundary regression became red, observing
grpcport: 0followed by an unrelated missing cluster-id failure instead of the required binding diagnostic. The mutation was fully restored, both worktrees were confirmed clean of mutation artifacts, and the focused tests passed again.TEST_SENSITIVITY=PASS
Validation
/nix/store; hermetic caches outside the candidate worktreego test -race . ./cmd/server -count=1bash scripts/agent-check-fullbash scripts/ai-bugfix-gate pre-pushf8c649fb6c072e02e16ed8dec5f48960d1bb35fbShared-library validation in formancehq/go-libs#673 includes its focused race suite, full race-enabled suite, pre-commit, CI, and exact-head NumaryBot approval.
Dependency ordering
Merge formancehq/go-libs#673 first, then update this PR to the resulting release tag if maintainers publish one. This candidate pins the exact reviewed shared commit and deliberately excludes the unrelated pyroscope work in Ledger #1798.
The candidate was rebased onto the refreshed release/v3.0 tip
46b21f68b671ab70e3219bd54dcb721f74eea4c4; the final Ledger head isf8c649fb6c072e02e16ed8dec5f48960d1bb35fb, and the dependency now tracks go-libs77516f9f3e01cd99633cdf55b223b1de24ff0e66.