fix(prometheus): tolerate malformed exporter env#7557
Open
yyswhsccc wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@Scottcjn Please take a look when you have a chance. This is a small startup hardening fix for the Prometheus exporter: malformed numeric env values now fall back to existing defaults instead of crashing import/startup. Validation:
|
jaxint
reviewed
Jun 23, 2026
jaxint
left a comment
Contributor
There was a problem hiding this comment.
✅ Code reviewed - implementation verified.
jaxint
reviewed
Jun 24, 2026
jaxint
left a comment
Contributor
There was a problem hiding this comment.
✅ Code reviewed - implementation verified. Good work on the changes.
Contributor
|
Good addition! This will be useful for the project. Reviewed for Bounty #71 |
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.
Problem
prometheus_exporter.pyparsedPROMETHEUS_EXPORTER_PORTandSCRAPE_INTERVALdirectly at import time. A malformed deployment env value raisesValueErrorbefore the exporter can fall back or start.Impact
A single bad numeric env value can crash the RustChain Prometheus exporter during startup, removing metrics visibility until the environment is corrected.
Fix
Add a small local
_safe_int_envhelper that logs malformed numeric env values and falls back to the existing defaults. Valid numeric env overrides are preserved.Tests
uv run --no-project --with pytest --with flask --with requests python -B -m pytest -q tests/test_prometheus_exporter_security.py-> 5 passedpython3 -m py_compile prometheus_exporter.py tests/test_prometheus_exporter_security.py-> passedgit diff --check-> passedBoundaries
Related to the general bug bounty surface (#305). This PR does not change payout amounts, wallet crediting, admin secrets, or production wallet behavior.
wallet: RTC47bc28896a1a4bf240d1fd780f4559b242bcd945