Skip to content

Preserve statsd_prefix from config when --statsd-prefix is not passed - #385

Open
r3wretrhy wants to merge 1 commit into
pgjones:mainfrom
r3wretrhy:fix/statsd-prefix-config-file-382
Open

r3wretrhy wants to merge 1 commit into
pgjones:mainfrom
r3wretrhy:fix/statsd-prefix-config-file-382

Conversation

@r3wretrhy

Copy link
Copy Markdown

--statsd-prefix was the only non-list CLI flag that used a concrete argparse default ("") instead of the shared sentinel. After a config file/object/toml load, main() only copies CLI values when they are not sentinel, but the empty-string default always won — so a statsd_prefix = "myapp." in hypercorn_config.py was wiped back to "" on every start unless the flag was also passed on the command line.

This switches --statsd-prefix to default=sentinel, matching --statsd-host and the other optional scalars. Config-file prefixes stick; an explicit --statsd-prefix still overrides.

# hypercorn_config.py: statsd_prefix = "myapp."
hypercorn -c file:hypercorn_config.py asgi:App
# before: config.statsd_prefix == ""
# after:  config.statsd_prefix == "myapp."

Tested with pytest tests/test___main__.py (18 passed), including a new case for a config-file prefix with no CLI flag and one for an explicit --statsd-prefix override.

Fixes #382.

--statsd-prefix used default="", so argparse always supplied an empty
string and overwrote any value loaded from a config file. Use the same
sentinel default as the other optional flags so file/object/toml config
keeps its prefix unless the flag is passed explicitly.

Fixes pgjones#382.

This branch has not been deployed

No deployments
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.

statsd_prefix ignored from non-cli option config

1 participant