readthedocs / sphinx-notfound-page

Create a custom 404 page with absolute URLs hardcoded
https://sphinx-notfound-page.readthedocs.io/
MIT License
51 stars 33 forks source link

Error with `sphinx-notfound-page` 1.0.3 - 'tuple' object has no attribute 'default' #240

Closed dgarcia360 closed 3 months ago

dgarcia360 commented 3 months ago

Context

I get the following error in some Sphinx-based projects with the latest release of the extension:

Extension error (notfound.extension): Handler <function validate_configs at 0x7f69c2a4caf0> for event 'config-inited' threw an exception (exception: 'tuple' object has no attribute 'default')

More details, I'm using:

Debugging

The issue might be here: https://github.com/readthedocs/sphinx-notfound-page/commit/64ed88f43b4aa0299ec168a60ff5ecfd2d8e1bc7#diff-83bfdb6415a043b1888e7ce5240bd78ea1f236af2f7094fcb5e7702f8672aa32R274

Is trying to access app.config.values.get("notfound_urls_prefix").default, but I'm not sure if the default is being defined.

humitos commented 3 months ago

We talked about this issue on https://github.com/readthedocs/sphinx-notfound-page/pull/236#pullrequestreview-2073228098. I thought it was already fixed 🤔

dgarcia360 commented 3 months ago

Thanks @humitos! I get the build working updating to Sphinx 7.3.0.

Most likely, this is the version where _Opt was included:

I'm happy to submit a PR changing:

if sphinx.version_info >= (7, 2)

To:

if sphinx.version_info >= (7, 3)
dgarcia360 commented 3 months ago

PR with the fix: https://github.com/readthedocs/sphinx-notfound-page/pull/241

humitos commented 3 months ago

notfound_urls_prefix values in conf.py are set to None or ``.

I'm not yet sure to understand why this wasn't catch by the test we have for this config: https://github.com/rtfd/sphinx-notfound-page/blob/ccdda4977159004aca945bdd1c249b08cf685afe/tests/test_urls.py#L162-L201

We will need to research a little more that so we can write a test case that pass/break depending on the code we are fixing.

humitos commented 3 months ago

I released 1.0.4, can you please confirm that it works as expected? 🙏🏼

dgarcia360 commented 3 months ago

Works fine, thanks!