Skip to content

[next] <py-config> doesn't handle syntax errors well #1700

@antocuni

Description

@antocuni

I have noticed that when contains invalid TOML, we have several unexpected things, but I could not find a common pattern so I'm reporting all of them here.

Case 1: invalid syntax

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>PyScript Error</title>
        <script type="module" src="https://cdn.jsdelivr.net/npm/@pyscript/core@latest"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@pyscript/core/dist/core.css">
        <py-config>
          [[fetch]]
              files = ["pyterminal.py"]this is a syntax error
        </py-config>

        <script type="py">
          print('hello')
        </script>
    </head>
</html>

Here I correctly get an error in the console:
image

However:

  1. errors should be displayed to the DOM by default
  2. the error message says something about JSON which is very confusing, since <py-config> is supposed to contain TOML

Case 2: another invalid syntax, completely ignored

        <py-config>
          this is invalid syntax
        </py-config>

        <script type="py">
          print('hello')
        </script>

In this case, the py-config is just silently ignored and hello is normally printed.
I would expect that in case of syntax error in the config, the execution of the page stops and the error is displayed to the DOM.

Case 3: I cannot really understand what's happening

        <py-config>
          [[fetch]]
          files = 
        </py-config>

        <script type="py">
          print('hello')
        </script>

Here I get yet another error, but also I see that it tries to fetch config.txt, which I don't really know where it comes from 🤔

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions