-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add JSON value for custom_extra_body #4246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Soulter
merged 2 commits into
AstrBotDevs:master
from
fluidcat:feat/provider_custom_extra_body
Dec 29, 2025
Merged
feat: add JSON value for custom_extra_body #4246
Soulter
merged 2 commits into
AstrBotDevs:master
from
fluidcat:feat/provider_custom_extra_body
Dec 29, 2025
+31
−3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - 我发现了 1 个问题,并留下了一些整体反馈:
- 在处理
json值时,confirmDialog中的JSON.parse(pair.value)如果输入不是合法 JSON 会抛出异常并导致对话框出错;建议在解析前增加校验/错误处理(例如使用 try/catch 并给用户反馈)。 - 在
initializeLocalKeyValuePairs中,typeof value === 'object'会把null和其他非普通对象也归类为json;如果这不是期望的行为,可以收紧类型检查(例如排除null或特定类),或者显式处理这些情况。
给 AI Agents 的提示
Please address the comments from this code review:
## Overall Comments
- When handling `json` values, `JSON.parse(pair.value)` in `confirmDialog` can throw and break the dialog if the input is invalid JSON; consider adding validation/error handling (e.g., try/catch with user feedback) before parsing.
- In `initializeLocalKeyValuePairs`, `typeof value === 'object'` will classify `null` and other non-plain objects as `json`; if that’s not desired, tighten the type check (e.g., exclude `null` or specific classes) or handle these cases explicitly.
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/ObjectEditor.vue:214-219` </location>
<code_context>
case 'boolean':
defaultValue = false
break
+ case 'json':
+ defaultValue = "{}"
+ break
</code_context>
<issue_to_address>
**issue (bug_risk):** JSON.parse on user input can throw and currently isn’t guarded, which may break the confirm flow.
If `pair.value` contains invalid JSON, `JSON.parse` will throw and likely break `confirmDialog()` and the save flow. Please wrap this in try/catch and either show a validation error or handle it gracefully so bad input doesn’t crash the UI.
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- When handling
jsonvalues,JSON.parse(pair.value)inconfirmDialogcan throw and break the dialog if the input is invalid JSON; consider adding validation/error handling (e.g., try/catch with user feedback) before parsing. - In
initializeLocalKeyValuePairs,typeof value === 'object'will classifynulland other non-plain objects asjson; if that’s not desired, tighten the type check (e.g., excludenullor specific classes) or handle these cases explicitly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When handling `json` values, `JSON.parse(pair.value)` in `confirmDialog` can throw and break the dialog if the input is invalid JSON; consider adding validation/error handling (e.g., try/catch with user feedback) before parsing.
- In `initializeLocalKeyValuePairs`, `typeof value === 'object'` will classify `null` and other non-plain objects as `json`; if that’s not desired, tighten the type check (e.g., exclude `null` or specific classes) or handle these cases explicitly.
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/ObjectEditor.vue:214-219` </location>
<code_context>
case 'boolean':
defaultValue = false
break
+ case 'json':
+ defaultValue = "{}"
+ break
</code_context>
<issue_to_address>
**issue (bug_risk):** JSON.parse on user input can throw and currently isn’t guarded, which may break the confirm flow.
If `pair.value` contains invalid JSON, `JSON.parse` will throw and likely break `confirmDialog()` and the save flow. Please wrap this in try/catch and either show a validation error or handle it gracefully so bad input doesn’t crash the UI.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Soulter
approved these changes
Dec 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:webui
The bug / feature is about webui(dashboard) of astrbot.
lgtm
This PR has been approved by a maintainer
size:M
This PR changes 30-99 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
部分LLM厂商自定义请求体参数不止是的基本类型,而是JSON。目前custom_extra_body只支持string、boolean、number,这里谈价JSON类型支持
Modifications / 改动点
修改了dashboard/src/components/shared/ObjectEditor.vue,添加JSON类型的添加、回显、提交支持
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
在用于
custom_extra_body的仪表盘键值对象编辑器中添加对 JSON 类型值的支持。新功能:
json作为值类型,并通过专用文本字段输入 JSON。Original summary in English
Summary by Sourcery
Add support for JSON-typed values in the dashboard key-value object editor used for custom_extra_body.
New Features: