[GH-ISSUE #7413] Cannot insert data into new file : no column named hash #14739

Closed
opened 2026-04-19 21:02:03 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Micropot on GitHub (Nov 27, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7413

Bug Report

Installation Method

Installation of the OpenWebui python lib with pip, running the openwebui into a docker as the doc mentionned.

Environment

  • Open WebUI Version: v0.4.4

  • Ollama (if applicable): v0.3.3

  • Operating System: Linux Fedora 9.4

  • Browser (if applicable): Edge
    Confirmation:

  • I have read and followed all the instructions provided in the README.md.

  • I am on the latest version of both Open WebUI and Ollama.

  • I have included the browser console logs.

  • I have included the Docker container logs.

  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

Creation of an html file based on the json input using the FileForm class and the Files.insert_new_files() then plot the html graph into an iframe.

Actual Behavior:

[Describe what actually happened.]

Return an error mentionning that table file as no column hash

Bug Summary:
While trying to create an html file into OpenWebUi, the hash argument is causing issue.
FileForm class has hash has Optional argument. But when using the insert_new_fillle function, it creates a File object who need a hash argument.

Reproduction Details

Steps to Reproduce:

  1. Create on object from the class FileForm
  2. Use the function Files.insert_new_file

Logs and Screenshots

Error creating tool: (sqlite3.OperationalError) table file has no column named hash
[SQL: INSERT INTO file (id, user_id, hash, filename, path, data, meta, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('4c556b92-c8f2-4425-91c7-748343fcfd11', '31505c76-ae44-4a53-b6a9-760e53227c7e', None, 'uploads/action_embed/graphic_viviane.html', 'uploads/action_embed/graphic_viviane.html', '{"data": [{"alignmentgroup": "True", "hovertemplate": "LABEL=%{x}
count=%{marker.color}", "legendgroup": "", "marker": {"color": [7 ... (8850 characters truncated) ... "legend": {"tracegroupgap": 0}, "title": {"text": "Count of Events"}, "barmode": "relative", "plot_bgcolor": "#F7FCFF", "paper_bgcolor": "#F7FCFF"}}', '{"name": "graphic_viviane.html", "content_type": "text/html", "size": 2, "path": "uploads/action_embed/graphic_viviane.html"}', 1732701343, 1732701343)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Mauvais graphique généré
ERROR python generation (sqlite3.OperationalError) no such column: file.hash
[SQL: SELECT file.id AS file_id, file.user_id AS file_user_id, file.hash AS file_hash, file.filename AS file_filename, file.path AS file_path, file.data AS file_data, file.meta AS file_meta, file.created_at AS file_created_at, file.updated_at AS file_updated_at
FROM file]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Additional Information

I think it comes from the difference beteween the class

class File(Base):
    __tablename__ = "file"
    id = Column(String, primary_key=True)
    user_id = Column(String)
    hash = Column(Text, nullable=True)

    filename = Column(Text)
    path = Column(Text, nullable=True)

    data = Column(JSON, nullable=True)
    meta = Column(JSON, nullable=True)

    created_at = Column(BigInteger)
    updated_at = Column(BigInteger)

and

class FileForm(BaseModel):
    id: str
    hash: Optional[str] = None
    filename: str
    path: str
    data: dict = {}
    meta: dict = {}

The function insert_new_file ask for a FileForm object and create a File object. The hash argument create a conflict.

def insert_new_file(self, user_id: str, form_data: FileForm) -> Optional[FileModel]:
        with get_db() as db:
            file = FileModel(
                **{
                    **form_data.model_dump(),
                    "user_id": user_id,
                    "created_at": int(time.time()),
                    "updated_at": int(time.time()),
                }
            )

            try:
                result = File(**file.model_dump())
                db.add(result)
                db.commit()
                db.refresh(result)
                if result:
                    return FileModel.model_validate(result)
                else:
                    return None
            except Exception as e:
                print(f"Error creating tool: {e}")
                return None
Originally created by @Micropot on GitHub (Nov 27, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/7413 # Bug Report ## Installation Method Installation of the OpenWebui python lib with pip, running the openwebui into a docker as the doc mentionned. ## Environment - **Open WebUI Version:** v0.4.4 - **Ollama (if applicable):** v0.3.3 - **Operating System:** Linux Fedora 9.4 - **Browser (if applicable):** Edge **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: Creation of an html file based on the json input using the FileForm class and the Files.insert_new_files() then plot the html graph into an iframe. ## Actual Behavior: [Describe what actually happened.] Return an error mentionning that table file as no column hash **Bug Summary:** While trying to create an html file into OpenWebUi, the hash argument is causing issue. FileForm class has hash has Optional argument. But when using the insert_new_fillle function, it creates a File object who need a hash argument. ## Reproduction Details **Steps to Reproduce:** 1. Create on object from the class FileForm 2. Use the function Files.insert_new_file ## Logs and Screenshots Error creating tool: (sqlite3.OperationalError) table file has no column named hash [SQL: INSERT INTO file (id, user_id, hash, filename, path, data, meta, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('4c556b92-c8f2-4425-91c7-748343fcfd11', '31505c76-ae44-4a53-b6a9-760e53227c7e', None, 'uploads/action_embed/graphic_viviane.html', 'uploads/action_embed/graphic_viviane.html', '{"data": [{"alignmentgroup": "True", "hovertemplate": "LABEL=%{x}<br>count=%{marker.color}<extra></extra>", "legendgroup": "", "marker": {"color": [7 ... (8850 characters truncated) ... "legend": {"tracegroupgap": 0}, "title": {"text": "Count of Events"}, "barmode": "relative", "plot_bgcolor": "#F7FCFF", "paper_bgcolor": "#F7FCFF"}}', '{"name": "graphic_viviane.html", "content_type": "text/html", "size": 2, "path": "uploads/action_embed/graphic_viviane.html"}', 1732701343, 1732701343)] (Background on this error at: https://sqlalche.me/e/20/e3q8) Mauvais graphique généré ERROR python generation (sqlite3.OperationalError) no such column: file.hash [SQL: SELECT file.id AS file_id, file.user_id AS file_user_id, file.hash AS file_hash, file.filename AS file_filename, file.path AS file_path, file.data AS file_data, file.meta AS file_meta, file.created_at AS file_created_at, file.updated_at AS file_updated_at FROM file] (Background on this error at: https://sqlalche.me/e/20/e3q8) ## Additional Information I think it comes from the difference beteween the class ```python class File(Base): __tablename__ = "file" id = Column(String, primary_key=True) user_id = Column(String) hash = Column(Text, nullable=True) filename = Column(Text) path = Column(Text, nullable=True) data = Column(JSON, nullable=True) meta = Column(JSON, nullable=True) created_at = Column(BigInteger) updated_at = Column(BigInteger) ``` and ```python class FileForm(BaseModel): id: str hash: Optional[str] = None filename: str path: str data: dict = {} meta: dict = {} ``` The function insert_new_file ask for a FileForm object and create a File object. The hash argument create a conflict. ```python def insert_new_file(self, user_id: str, form_data: FileForm) -> Optional[FileModel]: with get_db() as db: file = FileModel( **{ **form_data.model_dump(), "user_id": user_id, "created_at": int(time.time()), "updated_at": int(time.time()), } ) try: result = File(**file.model_dump()) db.add(result) db.commit() db.refresh(result) if result: return FileModel.model_validate(result) else: return None except Exception as e: print(f"Error creating tool: {e}") return None ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#14739