Skip to content

Commit 5de60dc

Browse files
committed
refac
1 parent a30b106 commit 5de60dc

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12-
- 🔒 **Public sharing permission bypass fix.** Users with write access to knowledge bases, tools, skills, prompts, and models could previously see and use the "Public" sharing option regardless of their actual sharing permissions, and direct API calls could bypass frontend restrictions entirely; both frontend and backend now properly enforce sharing.public_* permissions, silently stripping public grants when users lack the corresponding permission. [#21356](https://github.com/open-webui/open-webui/issues/21356), [#21358](https://github.com/open-webui/open-webui/pull/21358)
12+
- 🔒 **Public sharing permission bypass fix.** Users with write access to knowledge bases, tools, skills, prompts, and models could previously see and use the "Public" sharing option regardless of their actual sharing permissions, and direct API calls could bypass frontend restrictions entirely; both frontend and backend now properly enforce sharing.public\_\* permissions, silently stripping public grants when users lack the corresponding permission. [#21356](https://github.com/open-webui/open-webui/issues/21356), [#21358](https://github.com/open-webui/open-webui/pull/21358)
1313
- 🐘 **PostgreSQL analytics query fix.** The get_chat_ids_by_model_id function now works correctly with PostgreSQL by using GROUP BY with aggregate ordering instead of DISTINCT with non-aggregate ORDER BY, which PostgreSQL does not support. [Commit](https://github.com/open-webui/open-webui/commit/7bda6bf767d5d5c4dc1111465096a88e10b5030e)
1414
- 🐘 **Skills PostgreSQL compatibility fix.** Skills now work correctly with PostgreSQL by using SQLAlchemy's native JSON column type instead of the custom JSONField, which caused compatibility issues. [Commit](https://github.com/open-webui/open-webui/commit/b4c3f54f9648c4232a0fd6557703ffa66fcf4caa)
1515
- 🗑️ **Chat message deletion cascade fix.** Deleting chats now properly removes associated chat messages from the database, preventing orphaned message records from accumulating when chats or shared chats are deleted. [#21362](https://github.com/open-webui/open-webui/pull/21362)

backend/open_webui/utils/middleware.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ def serialize_output(output: list) -> str:
431431
if isinstance(ci_output, dict):
432432
output_json = json.dumps(ci_output, ensure_ascii=False)
433433
else:
434-
output_json = json.dumps({"result": str(ci_output)}, ensure_ascii=False)
434+
output_json = json.dumps(
435+
{"result": str(ci_output)}, ensure_ascii=False
436+
)
435437
output_attr = f' output="{html.escape(output_json)}"'
436438

437439
if status == "completed" or duration is not None or not is_last_item:
@@ -3134,8 +3136,6 @@ def set_last_text(out, text):
31343136
if re.search(end_tag_pattern, block_content):
31353137
end_flag = True
31363138

3137-
3138-
31393139
# Strip start and end tags from content
31403140
start_tag_pattern = rf"{re.escape(start_tag)}"
31413141
if start_tag.startswith("<") and start_tag.endswith(">"):
@@ -3683,12 +3683,16 @@ async def flush_pending_delta_data(threshold: int = 0):
36833683
# output.
36843684
last_item = output[-1] if output else None
36853685
last_item_type = (
3686-
last_item.get("type", "") if last_item else ""
3686+
last_item.get("type", "")
3687+
if last_item
3688+
else ""
36873689
)
36883690
inside_tag_block = (
36893691
last_item is not None
36903692
and last_item.get("status") == "in_progress"
3691-
and last_item.get("attributes", {}).get("type")
3693+
and last_item.get("attributes", {}).get(
3694+
"type"
3695+
)
36923696
!= "reasoning_content"
36933697
and (
36943698
last_item_type == "reasoning"
@@ -3704,7 +3708,10 @@ async def flush_pending_delta_data(threshold: int = 0):
37043708

37053709
if inside_tag_block:
37063710
# Append to the existing tag-based item
3707-
if last_item_type == "open_webui:code_interpreter":
3711+
if (
3712+
last_item_type
3713+
== "open_webui:code_interpreter"
3714+
):
37083715
last_item["code"] = (
37093716
last_item.get("code", "") + value
37103717
)
@@ -3769,7 +3776,10 @@ async def flush_pending_delta_data(threshold: int = 0):
37693776
msg_parts[-1]["text"] += value
37703777
else:
37713778
output[-1]["content"] = [
3772-
{"type": "output_text", "text": value}
3779+
{
3780+
"type": "output_text",
3781+
"text": value,
3782+
}
37733783
]
37743784

37753785
if DETECT_REASONING_TAGS:

backend/open_webui/utils/misc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def flush_pending():
236236
code_output = item.get("output", "")
237237

238238
if code:
239-
pending_content.append(f"<code_interpreter>\n{code}\n</code_interpreter>")
239+
pending_content.append(
240+
f"<code_interpreter>\n{code}\n</code_interpreter>"
241+
)
240242

241243
if code_output:
242244
if isinstance(code_output, dict):
@@ -246,7 +248,9 @@ def flush_pending():
246248
else:
247249
output_text = str(code_output)
248250
if output_text:
249-
pending_content.append(f"<code_interpreter_output>\n{output_text}\n</code_interpreter_output>")
251+
pending_content.append(
252+
f"<code_interpreter_output>\n{output_text}\n</code_interpreter_output>"
253+
)
250254

251255
elif item_type.startswith("open_webui:"):
252256
# Skip other extension types

0 commit comments

Comments
 (0)