mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #16381] [MERGED] fix: failure to bind metadata variable on insert for PGVECTOR_PGCRYPTO feature returning syntax error #10912
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16381
Author: @psy42a
Created: 8/8/2025
Status: ✅ Merged
Merged: 8/8/2025
Merged by: @tjbck
Base:
dev← Head:patch-1📝 Commits (1)
f3b0f7dFix 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
with CLA this time
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
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.