Skip to content

Config parse errors shouldn't terminate zensical serve #403

@edayot

Description

@edayot

Context

I'm currently using zensical with the CLI command zensical serve. While I'm developing / documenting my project, I often edit my zensical.toml config, to add new pages or modify paths.

I use VSCode as an IDE, which has an auto-save option.

Description

While I'm editing zenzical.toml, the file has temporarily an invalid syntax, internally the tomllib module in python raises tomllib.TOMLDecodeError. This error isn't catch and kills the development server.

I would expect the development server to report the error in the console, while just continuing to watch changes on files, while I finish writing my line / fixing the syntax error.

Related links

Use Cases

  • Anyone who is using the command doesn't have to retype it on syntax errors.

Visuals

Logs :

➜  ~/Documents/dev/beet git:(docs_contrib) ✗ uv run zensical serve
Serving /home/erwan/Documents/dev/beet/site on http://localhost:8000
Build started
+ /quick-start/builtin_plugins/
+ /quick-start/first_plugin/
+ /rationale/
+ /
+ /quick-start/get-started/
+ /overview/
Traceback (most recent call last):
  File "/home/erwan/Documents/dev/beet/.venv/bin/zensical", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/zensical/main.py", line 128, in execute_serve
    serve(os.path.abspath(config_file), kwargs)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/zensical/config.py", line 87, in parse_config
    return parse_zensical_config(path)
  File "/home/erwan/Documents/dev/beet/.venv/lib/python3.14/site-packages/zensical/config.py", line 95, in parse_zensical_config
    config = tomllib.load(f)
  File "/usr/lib/python3.14/tomllib/_parser.py", line 133, in load
    return loads(s, parse_float=parse_float)
  File "/usr/lib/python3.14/tomllib/_parser.py", line 174, in loads
    pos = key_value_rule(src, pos, out, header, parse_float)
  File "/usr/lib/python3.14/tomllib/_parser.py", line 403, in key_value_rule
    pos, key, value = parse_key_value_pair(src, pos, parse_float)
                      ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/tomllib/_parser.py", line 443, in parse_key_value_pair
    raise TOMLDecodeError("Expected '=' after a key in a key/value pair", src, pos)
tomllib.TOMLDecodeError: Expected '=' after a key in a key/value pair (at line 8, column 2)

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions