Skip to content

App breaks when descriptions contain newlines #87

@dionhaefner

Description

@dionhaefner

Description

See below.

Steps to reproduce

class InputSchema(BaseModel):
    foo: Differentiable[
        Array[
            (None, None, 3),
            Float32,
        ]
    ] = Field(description="hey\nthere")

Logs

2025-11-19 10:19:32.025 Script compilation error
Traceback (most recent call last):
  File "/Users/dion/.virtualenvs/science/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 553, in _run_script
    code = self._script_cache.get_bytecode(script_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dion/.virtualenvs/science/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_cache.py", line 72, in get_bytecode
    filebody = magic.add_magic(filebody, script_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dion/.virtualenvs/science/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/magic.py", line 46, in add_magic
    tree = ast.parse(code, script_path, "exec")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ast.py", line 52, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dion/codes/tesseract-streamlit/examples/jax_fem/app.py", line 245
    container_bar_params.caption("Vertex positions of the bar geometry. The shape is (num_bars, num_vertices, 3), where num_bars is the number of bars and num_vertices is the number of vertices per bar. The last dimension represents the x, y, z coordinates of each vertex.
                                 ^
SyntaxError: unterminated string literal (detected at line 245)
2025-11-19 10:19:32.027 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.

OS

Mac

Tesseract Streamlit version

main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions