fix(themes): resolve Kida 0.7.0 strict_undefined render errors#243
Merged
fix(themes): resolve Kida 0.7.0 strict_undefined render errors#243
Conversation
Kida 0.7.0's ?. operator raises on missing dict keys (it only short-circuits
on None), so templates that accessed optional dict/attribute fields without
a ?? fallback crashed on pages where those fields were absent. This affected
~800+ pages in the docs site (author pages without authors.yaml entries,
doc sections without discover: frontmatter, page heroes without lastmod).
Also: {% def %} macros always return Markup, not the raw {{ expr }} value —
parse_discover_config was returning a Markup string that looked like a dict
but failed on `.enabled` access. Refactored to inline `{% let %}` expressions.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…hangelog
- test_bdi_in_base_menu now asserts on the post-refactor template strings
(`<bdi>{{ _item_name }}</bdi>` and `<bdi>{{ child?.name ?? '' }}</bdi>`)
introduced when render_menu_item was hardened for Kida 0.7.0
strict_undefined.
- Add towncrier fragment describing the strict_undefined theme fixes so
the `fragment` CI job stops failing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Kida 0.7.0's
?.operator raises on missing dict keys (it only short-circuits onNone), so default-theme templates that accessed optional fields without a??fallback crashed on pages where those fields were absent — producing Build Error overlays for ~800 doc pages. Also discovered that Kida{% def %}macros always returnMarkup, not the raw{{ expr }}value, soparse_discover_configindoc/list.htmlwas returning a Markup string that broke on.enabledaccess.Changes
base.html—render_menu_itemnow extractsitem?.children,item?.href,item?.nameinto locals with??fallbacks so auto_nav items (which lackchildren) render safely.doc/list.html— replaced theparse_discover_configdef with inline{% let %}expressions; added?? nonetodiscover?.children/discover?.related.authors/single.html— switched allauthor.Xtoauthor?.X;page | author_viewcan returnNone.partials/page-hero/_macros.html— wrappedpage?.word_count,page?.date,params?.lastmod,params?.description, and_get_page_urlin??fallbacks.autodoc/openapi/partials/schema-viewer.html— added?? nonetoschema?.enum,schema?.example,schema?.items.Local build goes from 15 render errors / ~800 error-overlay pages → 0 render errors, 1486 pages rendered cleanly.
Test plan
bengal build --no-incrementalinsite/and confirm zero[R010]render errors🤖 Generated with Claude Code