Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'classes' in sphinx\search\__init__.py #13428

Open
ElpadoCan opened this issue Mar 12, 2025 · 2 comments
Open

KeyError: 'classes' in sphinx\search\__init__.py #13428

ElpadoCan opened this issue Mar 12, 2025 · 2 comments
Labels

Comments

@ElpadoCan
Copy link

ElpadoCan commented Mar 12, 2025

Describe the bug

When building the html files locally with make.bat html I get the error below. This does not happen with Sphinx<8.2. I can see that it comes from sphinx\search\__init__.py which did not exist prior v8 of Sphinx right? I hope this is enough information. Thanks!

Traceback (most recent call last):
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\cmd\build.py", line 432, in build_main
    app.build(args.force_all, args.filenames)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\application.py", line 426, in build
    self.builder.build_update()
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\__init__.py", line 375, in build_update
    self.build(
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\__init__.py", line 454, in build
    self.write(docnames, updated_docnames, method)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\__init__.py", line 735, in write
    self.write_documents(docnames)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\__init__.py", line 749, in write_documents
    self._write_serial(sorted_docnames)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\__init__.py", line 767, in _write_serial
    self.write_doc_serialized(docname, doctree)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\html\__init__.py", line 684, in write_doc_serialized
    self.index_page(docname, doctree, title)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\builders\html\__init__.py", line 1021, in index_page
    self.indexer.feed(pagename, filename, title, doctree)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 503, in feed
    word_store = self._word_collector(doctree)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 554, in _word_collector
    _feed_visit_nodes(
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 643, in _feed_visit_nodes
    _feed_visit_nodes(child, word_store=word_store, split=split, language=language)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 643, in _feed_visit_nodes
    _feed_visit_nodes(child, word_store=word_store, split=split, language=language)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 643, in _feed_visit_nodes
    _feed_visit_nodes(child, word_store=word_store, split=split, language=language)
  File "%homepath%\miniforge3\Lib\site-packages\sphinx\search\__init__.py", line 608, in _feed_visit_nodes
    elif isinstance(node, nodes.Element) and 'no-search' in node['classes']:
                                                            ~~~~^^^^^^^^^^^
  File "%homepath%\miniforge3\Lib\site-packages\docutils\nodes.py", line 602, in __getitem__
    return self.attributes[key]
            ~~~~~~~~~~~~~~~^^^^^
KeyError: 'classes'

How to Reproduce

Unfortunately, I don't know which of my documentation files is triggering this error (and I have many), however, the error does not happen with Sphinx<8.2.

Environment Information

Platform:              win32; (Windows-10-10.0.19045-SP0)
Python version:        3.12.6 | packaged by conda-forge | (main, Sep 22 2024, 14:01:26) [MSC v.1941 64 bit (AMD64)])
Python implementation: CPython
Sphinx version:        7.4.7
Docutils version:      0.21.2
Jinja2 version:        3.1.6
Pygments version:      2.19.1

Sphinx extensions

Loaded Extensions
=================

* sphinx.ext.mathjax (8.2.3)
* alabaster (0.7.16)
* sphinxcontrib.applehelp (2.0.0)
* sphinxcontrib.devhelp (2.0.0)
* sphinxcontrib.htmlhelp (2.1.0)
* sphinxcontrib.serializinghtml (2.0.0)
* sphinxcontrib.qthelp (2.0.0)
* sphinx.ext.duration (8.2.3)
* sphinx.ext.doctest (8.2.3)
* sphinx.ext.autodoc.preserve_defaults (8.2.3)
* sphinx.ext.autodoc.type_comment (8.2.3)
* sphinx.ext.autodoc.typehints (8.2.3)
* sphinx.ext.autodoc (8.2.3)
* sphinx.ext.autosummary (8.2.3)
* sphinx.ext.napoleon (8.2.3)
* sphinx_copybutton (0.5.2)
* sphinxcontrib.email (0.3.6)
* sphinx_tabs.tabs (unknown version)
* sphinx_toolbox.confval (3.9.0)
* sphinx_carousel.carousel (1.2.0)
* sphinxcontrib.video (unknown version)
* sphinxcontrib.jquery (4.1)
* sphinx_rtd_theme (unknown version)

Additional context

No response

@AA-Turner
Copy link
Member

Are you able to provide a minimal reproducer? If not, can you please try with third-party extensions removed?

A

@ElpadoCan
Copy link
Author

ElpadoCan commented Mar 13, 2025

Are you able to provide a minimal reproducer? If not, can you please try with third-party extensions removed?

A

I will try. Is there any way to know more than the traceback? For example, what causes the creation of the node dictionary without classes? Because I used pdb.set_trace and many of the nodes are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants