quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.55k stars 293 forks source link

"attempt to index a nil value (field 'caption_long')" error thrown when trying to preview a page with both a lightbox image and an embedded scanpy figure #10196

Closed nickvigilante closed 2 days ago

nickvigilante commented 3 days ago

Bug description

We have a documentation page that has both images using the standard Quarto syntax with the .lightbox class and an embedded Jupyter notebook cell containing a scanpy plot. In 1.4.557, Quarto was able to handle both at the same time. In 1.5.52, we now face an error.

If I disable the .lightbox class on all images on the page, it builds successfully. Also, if I delete the embed cell pointing to the scanpy plot, it builds successfully. The presence of both causes an error.

I've instructed my team not to use 1.5.52 until this issue is resolved, and the steps to downgrade are simple enough. This is also reproducible on 1.6.0.

Steps to reproduce

Using Quarto 1.5.52:

git clone https://github.com/nickvigilante/index-nil-value-caption-long-lightbox-bug
cd index-nil-value-caption-long-lightbox-bug
conda env create -f environment.yml
conda activate index-nil-value-caption-long-lightbox-bug
quarto preview

Expected behavior

The page renders correctly and shows both a royalty-free lightbox image of a cat and a scanpy scatter plot.

Actual behavior

The following error is thrown:

Error running filter /Applications/quarto/share/filters/main.lua:
/Applications/quarto/share/filters/main.lua:11765: attempt to index a nil value (field 'caption_long')
stack traceback:
        [C]: in ?
        [C]: in method 'walk'
        /Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
        (...tail calls...)
        /Applications/quarto/share/filters/main.lua:11762: in local 'filter_fn'
        /Applications/quarto/share/filters/main.lua:635: in function </Applications/quarto/share/filters/main.lua:625>
        (...tail calls...)
        [C]: in ?
        [C]: in method 'walk'
        /Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
        (...tail calls...)
        /Applications/quarto/share/filters/main.lua:1334: in local 'callback'
        /Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
        /Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>
stack traceback:
        /Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
        (...tail calls...)
        /Applications/quarto/share/filters/main.lua:11762: in local 'filter_fn'
        /Applications/quarto/share/filters/main.lua:635: in function </Applications/quarto/share/filters/main.lua:625>
        (...tail calls...)
        [C]: in ?
        [C]: in method 'walk'
        /Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
        (...tail calls...)
        /Applications/quarto/share/filters/main.lua:1334: in local 'callback'
        /Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
        /Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>
stack traceback:
        /Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
        (...tail calls...)
        /Applications/quarto/share/filters/main.lua:1334: in local 'callback'
        /Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
        /Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>

Your environment

Quarto check output

Quarto 1.5.52 [✓] Checking versions of quarto binary dependencies... Pandoc version 3.2.0: OK Dart Sass version 1.70.0: OK Deno version 1.41.0: OK Typst version 0.11.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.5.52 Path: /Applications/quarto/bin

[✓] Checking tools....................OK TinyTeX: (not installed) Chromium: (not installed)

[✓] Checking LaTeX....................OK Tex: (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK Version: 3.12.4 (Conda) Path: /Users/nickv/miniforge3/envs/index-nil-value-caption-long-lightbox-bug/bin/python Jupyter: 5.7.2 Kernels: ir, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK Version: 4.4.1 Path: /opt/homebrew/Cellar/r/4.4.1/lib/R LibPaths:

[✓] Checking Knitr engine render......OK

cscheid commented 3 days ago

Thanks for the report. Is it ok if we use your repo as a regression test?

nickvigilante commented 3 days ago

Yes, absolutely. I just added the MIT license to the repo.

cscheid commented 3 days ago

Ok. I have a fix already, PR coming up soon.

nickvigilante commented 3 days ago

Sounds good! No rush, because I'm testing this across our entire repo, so I want to see if there are others that fail for a similar reason.

cscheid commented 3 days ago

Just for the record, this is a downstream consequence of the Pandoc fix that changed how accessing some pandoc AST nodes would cause Plain [] to be inserted, so some of the code we have that would work is now finding nil instead.

(our internal record)