Conversation
修复了在Pre-response Script中context.responseData不是JSON格式的问题。
**问题根因:**
- 原代码在index.js:302使用条件 `\!yapiRes && response.body` 来判断是否需要重新解析JSON
- 但是 `\!yapiRes` 对于有效的falsy值(如 {}, [], 0, false, "")会错误地返回true
- 导致已经正确解析的JSON对象被重新解析,可能变成字符串格式
**修复方案:**
- 将条件改为 `(yapiRes === undefined || yapiRes === null) && response.body`
- 只有当response.data明确为undefined或null时才尝试重新解析
- 确保有效的JSON值(包括空对象、数组、数字、布尔值、字符串)正确传递给YApi
**影响范围:**
- YApi Pre-response Script中的context.responseData现在将正确接收JSON格式的数据
- 兼容所有有效的JSON值类型,包括falsy值
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: 郭立lee <leeguooooo@users.noreply.github.com>
|
Claude finished @leeguooooo's task —— View job Code Review Tasks
Code Review Results✅ Code Quality & Best PracticesExcellent fix! The change from Location: // Before (problematic):
if (!yapiRes && response.body) {
// After (correct):
if ((yapiRes === undefined || yapiRes === null) && response.body) {Why this is better:
✅ Bug Fix AnalysisRoot Cause Correctly Identified: The original condition
Fix Impact: Now only ✅ Performance ConsiderationsMinor Performance Improvement:
✅ Security AssessmentNo Security Concerns:
|
|
@claude 发布最新的 release |
|
Claude finished @leeguooooo's task —— View job • Claude finished preparing the release ✅ Release Creation Tasks
🚀 Release v4.4.6 ReadyI've updated the version in Release InformationVersion: Release Notes: ## 🐛 Bug Fixes
### Fixed JSON Response Data Format in Pre-response Script
修复了在Pre-response Script中context.responseData不是JSON格式的问题。
**问题根因:**
- 原代码使用条件 `!yapiRes` 来判断是否需要重新解析JSON
- 但是 `!yapiRes` 对于有效的falsy值(如 {}, [], 0, false, "")会错误地返回true
- 导致已经正确解析的JSON对象被重新解析,可能变成字符串格式
**修复方案:**
- 将条件改为 `(yapiRes === undefined || yapiRes === null) && response.body`
- 只有当response.data明确为undefined或null时才尝试重新解析
- 确保有效的JSON值(包括空对象、数组、数字、布尔值、字符串)正确传递给YApi
**影响范围:**
- YApi Pre-response Script中的context.responseData现在将正确接收JSON格式的数据
- 兼容所有有效的JSON值类型,包括falsy值Next StepsDue to tool permissions, please create the release manually:
|
修复了在Pre-response Script中context.responseData不是JSON格式的问题。
问题根因:
!yapiRes && response.body来判断是否需要重新解析JSON!yapiRes对于有效的falsy值(如 {}, [], 0, false, "")会错误地返回true修复方案:
(yapiRes === undefined || yapiRes === null) && response.body影响范围:
🤖 Generated with Claude Code