[PR #16299] [CLOSED] fix: PGVECTOR_PGCRYPTO syntax error from failure to bind metadata variable in some sqlalchamy/postgres versions #24090

Closed
opened 2026-04-20 05:14:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/16299
Author: @psy42a
Created: 8/5/2025
Status: Closed

Base: devHead: patch-1


📝 Commits (1)

  • f3b0f7d Fix syntax error where the previous use of :metadata::text in some sqlachamy/postgres versions doesn't bind at all

📊 Changes

1 file changed (+7 additions, -4 deletions)

View changed files

📝 backend/open_webui/retrieval/vector/dbs/pgvector.py (+7 -4)

📄 Description

Fix for Experimental PGVECTOR_PGCRYPTO feature - failure to bind metadata variable on insert

In testing of the experimental PGVECTOR_PGCRYPTO feature we found that it failed to process/upload any documents due to a syntax error raised from failure to bind the metadata variable in the form "pgp_sym_encrypt(:metadata::text, :key)" this proposed fix (potentially just removing ::text might also work) explicitly serialises the json as a text variable and ensures that sqlalchemy correctly treats it as text and binds it correctly. Tested in Openwebui version v0.6.18 using Postgres 17.4

3 changes were made to the insert / upsert functions:

  • Added json_metadata = json.dumps(item["metadata"]) as seperate line
  • updated reference where this field is passed into sqlalchemy to "metadata_text": json_metadata,
  • and updated the pgp_sym_encrypt(:metadata_text, :key) line accordingly in the insert and upsert functions

We have then validated upload was successful for the document_chunk table with text, vmetadata fields defined as bytea fields and validated document retrieval and image summary of pdf works as expected using docling and the image summary api functionality.

Fixed

  • Corrected PGVECTOR_PGCRYPTO implementation to remove syntax error relating to metadata field
    • [Reference any related issues, commits, or other relevant information]

Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreements (CLA) and Open WebUI specific Contributor License Agreements, and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/16299 **Author:** [@psy42a](https://github.com/psy42a) **Created:** 8/5/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`f3b0f7d`](https://github.com/open-webui/open-webui/commit/f3b0f7d3583e2bfa0f186129056275276146958f) Fix syntax error where the previous use of :metadata::text in some sqlachamy/postgres versions doesn't bind at all ### 📊 Changes **1 file changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/retrieval/vector/dbs/pgvector.py` (+7 -4) </details> ### 📄 Description # Fix for Experimental PGVECTOR_PGCRYPTO feature - failure to bind metadata variable on insert In testing of the experimental PGVECTOR_PGCRYPTO feature we found that it failed to process/upload any documents due to a syntax error raised from failure to bind the metadata variable in the form "pgp_sym_encrypt(:metadata::text, :key)" this proposed fix (potentially just removing ::text might also work) explicitly serialises the json as a text variable and ensures that sqlalchemy correctly treats it as text and binds it correctly. Tested in Openwebui version v0.6.18 using Postgres 17.4 3 changes were made to the insert / upsert functions: - Added json_metadata = json.dumps(item["metadata"]) as seperate line - updated reference where this field is passed into sqlalchemy to "metadata_text": json_metadata, - and updated the pgp_sym_encrypt(:metadata_text, :key) line accordingly in the insert and upsert functions We have then validated upload was successful for the document_chunk table with text, vmetadata fields defined as bytea fields and validated document retrieval and image summary of pdf works as expected using docling and the image summary api functionality. ### Fixed - Corrected PGVECTOR_PGCRYPTO implementation to remove syntax error relating to metadata field - [Reference any related issues, commits, or other relevant information] Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreements (CLA)](https://github.com/CONTRIBUTOR_LICENSE_AGREEMENT) and [Open WebUI specific Contributor License Agreements](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 05:14:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#24090