Skip to content

Trailing whitespace in CSV column name causes "sqlite3.ProgrammingError: You did not supply a value for binding 2"

File: (trailing space in "col ")

id,col 
foo,bar

causes (paths obfuscated)

$ sphinx-build -b html source build\html -T
Running Sphinx v4.1.0
loading translations [cs]... done
loading pickled environment... done

Traceback (most recent call last):
File "venv\lib\site-packages\sphinx\events.py", line 101, in emit
results.append(listener.handler(self.app, *args))
File "venv\lib\site-packages\sphinxcontrib\constdata\flatfiles.py", line 319, in cache_flatfiles
AutodetectFileToDb(settings, rel_path).run()
File "venv\lib\site-packages\sphinxcontrib\constdata\flatfiles.py", line 272, in run
clazz(self.settings, self.rel_path).run()
File "venv\lib\site-packages\sphinxcontrib\constdata\flatfiles.py", line 223, in run
self.save_rows_to_db(reader)
File "venv\lib\site-packages\sphinxcontrib\constdata\flatfiles.py", line 194, in save_rows_to_db
self.sql_command.execute(sql, new_row_dict)
File "venv\lib\site-packages\sphinxcontrib\constdata\flatfiles.py", line 40, in execute
self.conn.cursor().execute(sql, params or {})
sqlite3.ProgrammingError: You did not supply a value for binding 2.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "venv\lib\site-packages\sphinx\cmd\build.py", line 276, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "venv\lib\site-packages\sphinx\application.py", line 270, in __init__
self._init_builder()
File "venv\lib\site-packages\sphinx\application.py", line 328, in _init_builder
self.events.emit('builder-inited')
File "venv\lib\site-packages\sphinx\events.py", line 109, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function cache_flatfiles at 0x000001E751988DC0> for event 'builder-inited' threw an exception (exception: You did not supply a value for binding 2.)

Extension error (sphinxcontrib.constdata.flatfiles):
Handler <function cache_flatfiles at 0x000001E751988DC0> for event 'builder-inited' threw an exception (exception: You did not supply a value for binding 2.)

pip freeze:

alabaster==0.7.12
Babel==2.9.0
beautiful-ansi==0.1.7
certifi==2021.10.8
charset-normalizer==2.0.8
click==8.0.3
colorama==0.4.4
docutils==0.16
idna==3.3
imagesize==1.3.0
Jinja2==3.0.3
MarkupSafe==2.0.1
numpy==1.22.1
packaging==21.3
pandas==1.3.5
pbr==5.8.0
Pillow==8.3.2
pyaml==21.10.1
Pygments==2.10.0
pyparsing==3.0.6
python-dateutil==2.8.2
pytz==2021.3
PyYAML==6.0
requests==2.26.0
six==1.16.0
snowballstemmer==2.2.0
Sphinx==4.1.0
sphinx-intl==2.0.1
sphinx-rtd-theme==0.5.1
sphinx-tabs==3.2.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib.constdata==1.0.9
urllib3==1.26.7

OS: Windows 11