pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
561 stars 304 forks source link

Error: e.map is not a function #1723

Closed dstansby closed 1 month ago

dstansby commented 4 months ago

I'm trying to get an up to date version of pydata-sphinx-theme working with Matplotlib (https://github.com/matplotlib/matplotlib/pull/27658). With the current main branch of pydata-sphinx-theme search/theme changing/version switching isn't working, and I think this is because of the javascript error we're getting,

Uncaught (in promise) TypeError: e.map is not a function
    g https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0:1
    937 https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0:1
[pydata-sphinx-theme.js:1:4657](https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0)

The code that is triggering this is

const n=(e=e.map((e=>(e.match=e.version==DOCUMENTATION_OPTIONS.theme_switcher_version_match,e.preferred=e.preferred||!1,"name"in e||(e.name=e.version),e)))).map((e=>e.preferred&&e.match)).some(Boolean)

It looks like this is some minified(???) javascript, so I'm not sure how to proceed with debugging. Any pointers welcome (is there a way to turn off the squashing of all the javascript into one line?)

A doc build that has this error is here: https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/index.html

drammock commented 4 months ago

Looks like here:

https://github.com/pydata/pydata-sphinx-theme/blob/99f9b1c29854ee0f88884e032acc1997dfae370e/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js#L386-399

I'm away for the next week or so, so can't be of much help right away, but maybe seeing the unminified version will be enough for you to figure it out without me 🤞

QuLogic commented 4 months ago

This is because the version switcher appears to be trying to load https://output.circle-artifacts.com/_static/switcher.json which is obviously going to not work. Has the option for the version switcher URL changed?

There's an if (data) { around the caller to populateVersionSwitcher, but it appears that's not a sufficient condition?

MridulS commented 1 month ago

I tried to recreate this issue, but it seems to work?

From one of the recent builds on matplotlib https://output.circle-artifacts.com/output/job/6954838a-52ab-43ed-8fcc-ddfb47b50117/artifacts/0/doc/build/html/index.html, I can pick a version. It just redirects me to an old build like https://matplotlib.org/3.8.4/

The javascript error is still in the console, but not sure if that's causing the issue.

dstansby commented 1 month ago

Yeah, I think worth closing if noone else can easily reproduce. I can't either, can always re-open if I run across it again.

QuLogic commented 1 month ago

I think the original error was fixed by matplotlib/matplotlib#27658, which pointed the switcher to the correct path on CircleCI. If you curl https://output.circle-artifacts.com/_static/switcher.json, then you get {"message":"Route Not Found"}, which is valid JSON, but just not at all in the format expected of the version switcher data.

I'm not sure why there's still a warning in the console, but it appears that it's a different error? It looks like Uncaught (in promise) TypeError: e is null.