From 8e17c94cc6892a03a1b2bf16a5bf458339e2090a Mon Sep 17 00:00:00 2001 From: aryansk <70511529+aryansk@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:07:33 +0530 Subject: [PATCH] Fix AssertionError when confval default contains cross-reference The confval directive's :default: option is formatted via parse_inline into a field_body. Previously it placed inline nodes directly into field_body, so a reference like :confval:`conf1` inside :default: had a parent of field_body (not a TextElement). The HTML writer then hit the assert for non-TextElement parents: assert len(node) == 1 and isinstance(node[0], nodes.image) Wrapping the parsed inline nodes in a paragraph (a TextElement) fixes the structure, so references are inside a paragraph inside field_body, matching normal field handling. Fixes sphinx-doc/sphinx#14117 Co-authored-by: Muse Spark Co-authored-by: Aryan Singh K <70511529+aryansk@users.noreply.github.com> AI disclosure: Muse Spark assisted in analysis and fix drafting; changes reviewed and tested manually (reproduction with :confval: in :default: now builds, HTML contains link, 20 test_domain_std tests pass). --- sphinx/domains/std/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/domains/std/__init__.py b/sphinx/domains/std/__init__.py index f88aa97b40e..a76508ba997 100644 --- a/sphinx/domains/std/__init__.py +++ b/sphinx/domains/std/__init__.py @@ -170,7 +170,7 @@ def format_type(self, type_: str) -> tuple[nodes.field, list[system_message]]: field = nodes.field( '', nodes.field_name('', _('Type')), - nodes.field_body('', *parsed), + nodes.field_body('', nodes.paragraph('', '', *parsed)), ) return field, msgs @@ -180,7 +180,7 @@ def format_default(self, default: str) -> tuple[nodes.field, list[system_message field = nodes.field( '', nodes.field_name('', _('Default')), - nodes.field_body('', *parsed), + nodes.field_body('', nodes.paragraph('', '', *parsed)), ) return field, msgs