[GH-ISSUE #7564] File upload Error 'NoneType' object has no attribute 'encode' #53461

Closed
opened 2026-05-05 14:47:04 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @prasadautomationtesting on GitHub (Dec 3, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7564

I'm encountering an error when attempting to upload files through UI, as indicated by the following message: 'NoneType object has no attribute "encode"'.

To better understand the issue, I've included some additional details below.

UI Screen print:

NoneType Error

UI Resonse:

UI Response

Backend Request:

Request

Backend Response:

Response

Platform: Windows 10
Browser: Chrome - 131.0.6778.86 (Official Build) (64-bit)
Open WebUI: 0.4.7

Attachment:

image

Note: I tried after cleaning the browser cookies as well but no luck.

Originally created by @prasadautomationtesting on GitHub (Dec 3, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/7564 I'm encountering an error when attempting to upload files through UI, as indicated by the following message: '**NoneType object has no attribute "encode"**'. To better understand the issue, I've included some additional details below. **UI Screen print:** <img width="616" alt="NoneType Error" src="https://github.com/user-attachments/assets/86dc6377-1ab7-47b5-a4ce-5f772c9ae29c"> **UI Resonse:** <img width="583" alt="UI Response" src="https://github.com/user-attachments/assets/dc58bd32-edc0-4b48-837d-54ca61c0ca35"> **Backend Request:** <img width="347" alt="Request" src="https://github.com/user-attachments/assets/41679630-3e62-4254-9e33-8bcbe90bf3ad"> **Backend Response:** <img width="358" alt="Response" src="https://github.com/user-attachments/assets/910cc4e9-dd4c-4dbd-b9c0-a5befaf3311f"> **Platform:** Windows 10 **Browser**: Chrome - 131.0.6778.86 (Official Build) (64-bit) **Open WebUI:** 0.4.7 **Attachment:** ![image](https://github.com/user-attachments/assets/1971e487-81ae-4022-abf0-9e17174620f3) Note: I tried after cleaning the browser cookies as well but no luck.
Author
Owner

@Jazzy96 commented on GitHub (Dec 4, 2024):

I have encountered it as well. v0.4.7

<!-- gh-comment-id:2516526613 --> @Jazzy96 commented on GitHub (Dec 4, 2024): I have encountered it as well. v0.4.7
Author
Owner

@Simi5599 commented on GitHub (Dec 4, 2024):

I had this error. It seems that in my case, the error was caused by the Embedding Model in the Admin Panel. I had to retype the default embedding model and then press the button on the right. After that, the error disappeared.

Screenshot 2024-12-04 153031

<!-- gh-comment-id:2517614329 --> @Simi5599 commented on GitHub (Dec 4, 2024): I had this error. It seems that in my case, the error was caused by the Embedding Model in the Admin Panel. I had to retype the default embedding model and then press the button on the right. After that, the error disappeared. ![Screenshot 2024-12-04 153031](https://github.com/user-attachments/assets/64aa364b-3ea3-40ab-b6c5-eb9d9b587522)
Author
Owner

@prasadautomationtesting commented on GitHub (Dec 4, 2024):

@Simi5599 : It works for me too after following your workaround. Thanks!

Nevertheless, keeping the defect opened for the fix.

<!-- gh-comment-id:2517675543 --> @prasadautomationtesting commented on GitHub (Dec 4, 2024): @Simi5599 : It works for me too after following your workaround. Thanks! Nevertheless, keeping the defect opened for the fix.
Author
Owner

@Simi5599 commented on GitHub (Dec 4, 2024):

I am looking for the source code to see if i can get this to work or maybe the maintainer of the repo will do this before me ;)

<!-- gh-comment-id:2517682905 --> @Simi5599 commented on GitHub (Dec 4, 2024): I am looking for the source code to see if i can get this to work or maybe the maintainer of the repo will do this before me ;)
Author
Owner

@Simi5599 commented on GitHub (Dec 4, 2024):

UPDATE: I think i did it!

In the file located in /backend/open_webui/apps/retrieval/main.py I made the following corrections:

  1. I created a variable default_embedding_model="sentence-transformers/all-MiniLM-L6-v2"

  2. In the function save_docs_to_vector_db I added the following lines at the very beginning:

If the embedding model is empty i am setting it back to the default value

if not app.state.config.RAG_EMBEDDING_MODEL or app.state.config.RAG_EMBEDDING_MODEL.strip() == "":
    app.state.config.RAG_EMBEDDING_MODEL=default_embedding_model
    update_embedding_model(app.state.config.RAG_EMBEDDING_MODEL)
    app.state.EMBEDDING_FUNCTION = get_embedding_function(
        app.state.config.RAG_EMBEDDING_ENGINE,
        app.state.config.RAG_EMBEDDING_MODEL,
        app.state.sentence_transformer_ef,
        (
            app.state.config.OPENAI_API_BASE_URL
            if app.state.config.RAG_EMBEDDING_ENGINE == "openai"
            else app.state.config.OLLAMA_BASE_URL
        ),
        (
            app.state.config.OPENAI_API_KEY
            if app.state.config.RAG_EMBEDDING_ENGINE == "openai"
            else app.state.config.OLLAMA_API_KEY
        ),
        app.state.config.RAG_EMBEDDING_BATCH_SIZE,
    )
    log.info(f"Embedding model was empty. Set to default: {default_embedding_model}")

The code basically resets the empty RAG_EMBEDDING_MODEL to the default value stored in a variable.

If @tjbck can review this, I can create a PR or let him handle the commit ;)

PROOF:

  1. Let's set the Embedding Model to "" to recreate the issue Screenshot 2024-12-04 231802
  2. Let's feed the LMM with a .pdf file and ask a question Screenshot 2024-12-04 231836
  3. We can observe that the Embedding Model has beed restored to the default value
    Screenshot 2024-12-04 231849
<!-- gh-comment-id:2518679586 --> @Simi5599 commented on GitHub (Dec 4, 2024): UPDATE: I think i did it! In the file located in `/backend/open_webui/apps/retrieval/main.py` I made the following corrections: 1. I created a variable `default_embedding_model="sentence-transformers/all-MiniLM-L6-v2"` 2. In the function `save_docs_to_vector_db` I added the following lines at the very beginning: # If the embedding model is empty i am setting it back to the default value if not app.state.config.RAG_EMBEDDING_MODEL or app.state.config.RAG_EMBEDDING_MODEL.strip() == "": app.state.config.RAG_EMBEDDING_MODEL=default_embedding_model update_embedding_model(app.state.config.RAG_EMBEDDING_MODEL) app.state.EMBEDDING_FUNCTION = get_embedding_function( app.state.config.RAG_EMBEDDING_ENGINE, app.state.config.RAG_EMBEDDING_MODEL, app.state.sentence_transformer_ef, ( app.state.config.OPENAI_API_BASE_URL if app.state.config.RAG_EMBEDDING_ENGINE == "openai" else app.state.config.OLLAMA_BASE_URL ), ( app.state.config.OPENAI_API_KEY if app.state.config.RAG_EMBEDDING_ENGINE == "openai" else app.state.config.OLLAMA_API_KEY ), app.state.config.RAG_EMBEDDING_BATCH_SIZE, ) log.info(f"Embedding model was empty. Set to default: {default_embedding_model}") The code basically resets the empty `RAG_EMBEDDING_MODEL` to the default value stored in a variable. If @tjbck can review this, I can create a PR or let him handle the commit ;) PROOF: 1. Let's set the Embedding Model to "" to recreate the issue ![Screenshot 2024-12-04 231802](https://github.com/user-attachments/assets/0b6cc0a3-d189-4b63-a8aa-04069084703c) 2. Let's feed the LMM with a .pdf file and ask a question ![Screenshot 2024-12-04 231836](https://github.com/user-attachments/assets/10a69dda-af3d-4282-8c56-b44db026b815) 3. We can observe that the Embedding Model has beed restored to the default value ![Screenshot 2024-12-04 231849](https://github.com/user-attachments/assets/fc32cb2f-aa4e-4760-bad3-7bfb06951311)
Author
Owner

@i0ntempest commented on GitHub (Dec 6, 2024):

Apparantly this can also be triggered if the embedding model could not be downloaded due to bad network conditions.

<!-- gh-comment-id:2523926650 --> @i0ntempest commented on GitHub (Dec 6, 2024): Apparantly this can also be triggered if the embedding model could not be downloaded due to bad network conditions.
Author
Owner

@GrayXu commented on GitHub (Dec 23, 2024):

Sometimes I encounter this issue even without modifying the embedding model configuration, and it only returns to normal after resetting the vector database.

<!-- gh-comment-id:2559364601 --> @GrayXu commented on GitHub (Dec 23, 2024): Sometimes I encounter this issue even without modifying the embedding model configuration, and it only returns to normal after resetting the vector database.
Author
Owner

@silentoplayz commented on GitHub (Dec 25, 2024):

Sometimes I encounter this issue even without modifying the embedding model configuration, and it only returns to normal after resetting the vector database.

This issue has been possibly fixed on the dev branch with this commit: 4b7f0c5be1

<!-- gh-comment-id:2561583290 --> @silentoplayz commented on GitHub (Dec 25, 2024): > Sometimes I encounter this issue even without modifying the embedding model configuration, and it only returns to normal after resetting the vector database. This issue has been possibly fixed on the `dev` branch with this commit: https://github.com/open-webui/open-webui/commit/4b7f0c5be11ef437301f9ffa5c68fc52fbb37516
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#53461