Skip to content

Commit

Permalink
fix: http parse
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Jan 20, 2025
1 parent d6f7355 commit 3c63132
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docSite/content/zh-cn/docs/development/upgrading/4819.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ weight: 806
4. 优化 - 统一分页加载代码。
5. 优化 - 对话页面加载时,可配置是否为独立页面。
6. 修复 - 语雀文件库导入时,嵌套文件内容无法展开的问题。
7. 修复 - 工作流编排中,LLM 参数无法关闭问题。
7. 修复 - 工作流编排中,LLM 参数无法关闭问题。
8. 修复 - HTTP 接口适配对象字符串解析。
1 change: 1 addition & 0 deletions packages/service/core/workflow/dispatch/plugin/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
showStatus: false
};
});

const runtimeVariables = {
...filterSystemVariables(props.variables),
appId: String(plugin.id)
Expand Down
16 changes: 13 additions & 3 deletions packages/service/core/workflow/dispatch/tools/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,16 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
if (typeof val === 'object') return JSON.stringify(val);

if (typeof val === 'string') {
const str = JSON.stringify(val);
return str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
try {
const parsed = JSON.parse(val);
if (typeof parsed === 'object') {
return JSON.stringify(parsed);
}
return val;
} catch (error) {
const str = JSON.stringify(val);
return str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
}
}

return String(val);
Expand Down Expand Up @@ -235,7 +243,9 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
}
if (!httpJsonBody) return {};
if (httpContentType === ContentTypes.json) {
return json5.parse(replaceJsonBodyString(httpJsonBody));
httpJsonBody = replaceJsonBodyString(httpJsonBody);
console.log(httpJsonBody);
return json5.parse(httpJsonBody);
}

// Raw text, xml
Expand Down

0 comments on commit 3c63132

Please sign in to comment.