v0.2.0
telegram-menu-builder 0.2.0
This release fixes a critical correctness bug in async usage, hardens the
dependency posture, and adds a full documentation site, CI, and project tooling.
π Fixed
- Critical: callback data is no longer lost when a menu is built inside a running
event loop.add_item()previously discarded the handler and parameters in async
contexts (the normal Telegram-bot case), producing buttons with emptycallback_data.
Encoding is now deferred tobuild_async()so every item is encoded correctly. MenuBuilder.build()now works when called inside a running event loop (it runs the
async build on a short-lived worker thread) instead of raisingRuntimeError. In async
code, preferawait build_async().add_submenu()no longer stores the non-serializable submenu builder in callback params;
only a JSON-safe_submenu_idis stored, with the builder kept in an internal registry
accessible via the newget_submenu().__version__is now single-sourced from package metadata (was hard-coded and drifted).- Hardened the deterministic dedup hash with
hashlib.md5(..., usedforsecurity=False).
β¨ Added
- Exported the exception hierarchy (
MenuBuilderError,EncodingError,DecodingError,
StorageError,ValidationError) from the package root, plusMenuBuilder.get_submenu(). - MkDocs Material documentation site (API reference, guides, security and
dependency/CVE audit, Python-compatibility analysis). - Tests for the router, storage backends, type validators, and package metadata
(coverage ~62% β ~90%). - CI workflow (ruff, black, mypy, pyright, pytest, pip-audit) on every push/PR, plus a
docs-deploy workflow;SECURITY.md, Dependabot, and issue/PR templates.
π§ Changed
- Raised the pydantic floor to
>=2.4to exclude CVE-2024-3772 (ReDoS in pydantic
email validation, fixed in 2.4.0). The library does not use email validation, so it was
never exploitable here β this is defense-in-depth. StorageStrategynow subclassesenum.StrEnum; refactored navigation buttons and
MenuRouter.route()(no behavior change).
Full changelog: https://github.com/smoxy/telegram-menu-builder/blob/v0.2.0/CHANGELOG.md