Fix bug which caused metric publishing to not accept query string parameters in ASGI app by hacksparr0w · Pull Request #1125 · prometheus/client_python

Conversation

@hacksparr0w

The _bake_output function in exposition.py expects the params argument to be a dict[str, Any] but the ASGI interface does not handle encoding, thus the parameters are passed in as dict[bytes, Any].

Signed-off-by: hack <hacksparr0w@protonmail.com>

csmarchbanks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Would you be willing to write a test for this please? Or add enough type hinting that it would be caught by mypy.

Signed-off-by: hacksparr0w <hacksparr0w@protonmail.com>

@hacksparr0w

I isolated the bug into a test case. Codifying this into type hints would be non-trivial since the used parse_qs function from urllib.parse is not typed and returns Any.

csmarchbanks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

2 participants

@hacksparr0w @csmarchbanks