Skip to content

Fix bug which caused metric publishing to not accept query string parameters in ASGI app - #1125

Merged
csmarchbanks merged 2 commits into
prometheus:masterfrom
hacksparr0w:master
Sep 3, 2025
Merged

Fix bug which caused metric publishing to not accept query string parameters in ASGI app#1125
csmarchbanks merged 2 commits into
prometheus:masterfrom
hacksparr0w:master

Conversation

@hacksparr0w

Copy link
Copy Markdown
Contributor

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 csmarchbanks left a comment

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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 csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@csmarchbanks
csmarchbanks merged commit 9e3eb6c into prometheus:master Sep 3, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants