Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error message should be clearer when there's a syntax error in the TOML fileΒ #1256

@tvst

Description

@tvst

Steps to reproduce

  1. Create config.toml that has a syntax error, like this:
server.port=
  1. Run a script with Streamlit (e.g. streamlit hello)

Expected behavior:

We should see an error like this on the console:

ValueError: Error parsing ~/.streamlit/config.toml. This is most likely due to a syntax error in the TOML file. Please fix it and try again.

[Original exception from the toml parser goes here]

...where the "original exception" is the part of the error below that ends with toml.decoder.TomlDecodeError: Empty value is invalid (line 1 column 1 char 0).

Actual behavior:

We see this error on the console, which is not super clear:

Traceback (most recent call last):
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/toml/decoder.py", line 456, in loads
    multibackslash)
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/toml/decoder.py", line 725, in load_line
    value, vtype = self.load_value(pair[1], strictly_valid)
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/toml/decoder.py", line 739, in load_value
    raise ValueError("Empty value is invalid")
ValueError: Empty value is invalid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/__init__.py", line 103, in <module>
    from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/DeltaGenerator.py", line 27, in <module>
    from streamlit import caching
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/caching.py", line 40, in <module>
    from streamlit.hashing import Context
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/hashing.py", line 40, in <module>
    from streamlit.folder_black_list import FolderBlackList
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/folder_black_list.py", line 39, in <module>
    if config.get_option("global.developmentMode"):
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/config.py", line 90, in get_option
    parse_config_file()
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/config.py", line 888, in parse_config_file
    _update_config_with_toml(file_contents, filename)
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/streamlit/config.py", line 810, in _update_config_with_toml
    parsed_config_file = toml.loads(raw_toml)
  File "/home/tvst/.local/share/virtualenvs/py3.7-gDeIkMOX/lib/python3.7/site-packages/toml/decoder.py", line 458, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Empty value is invalid (line 1 column 1 char 0)

Is this a regression?

no

Debug info

  • Streamlit version: 0.56.0
  • Python version: 3.7

Additional information

Source: https://discuss.streamlit.io/t/cant-import-streamlit-anymore/2288/2


Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you'd like the Streamlit team to prioritize this feature request, please use the πŸ‘ (thumbs up emoji) reaction in response to the initial post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:debuggingRelated to debugging capabilitiesfeature:configRelated to `config.toml` and config optionstype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions