Skip to content
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

升级到最新版本后修改文档时报错 #2371

Open
sunl888 opened this issue Oct 19, 2021 · 3 comments · May be fixed by #2374
Open

升级到最新版本后修改文档时报错 #2371

sunl888 opened this issue Oct 19, 2021 · 3 comments · May be fixed by #2374

Comments

@sunl888
Copy link

sunl888 commented Oct 19, 2021

版本号

1.10.2

什么问题

今天升级到最新版本后修改文档时报错。

[ 2021/10/19 下午1:57:06 ] [ error ] Cannot read property 'toObject' of null
TypeError: Cannot read property 'toObject' of null
    at projectModel.handleEnvNullData (/yapi/vendors/server/models/project.js:85:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async interfaceController.autoAddTag (/yapi/vendors/server/controllers/interface.js:396:25)
    at async interfaceController.up (/yapi/vendors/server/controllers/interface.js:825:5)
    at async /yapi/vendors/server/utils/commons.js:436:9
    at async module.exports (/yapi/vendors/server/middleware/mockServer.js:152:15)

如何复现此问题

修改任意接口文档。

什么浏览器

Chrome

什么系统(Linux, Windows, macOS)

操作的电脑是Windows,服务器是Linux

@shcw
Copy link

shcw commented Feb 21, 2022

我的情况是 编辑接口 带tag 保存报错 提示如下

[ error ] Cannot read property 'toObject' of null
TypeError: Cannot read property 'toObject' of null
    at projectModel.handleEnvNullData (/yapi/vendors/server/models/project.js:85:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async interfaceController.autoAddTag (/yapi/vendors/server/controllers/interface.js:396:25)
    at async interfaceController.up (/yapi/vendors/server/controllers/interface.js:825:5)
    at async /yapi/vendors/server/utils/commons.js:436:9
    at async module.exports (/yapi/vendors/server/middleware/mockServer.js:152:15)

解决的方法是:
server/models/project.js:83
修改为

handleEnvNullData(data){
    if (data == null) {
      return false;
    }
    data = data.toObject();
    data.toObject = ()=> data;

添加了

if (data == null) {
      return false;
    }

不知道大佬们有没有更好的解决办法~

@vvky
Copy link

vvky commented Sep 25, 2023

我的情况是 编辑接口 带tag 保存报错 提示如下

[ error ] Cannot read property 'toObject' of null
TypeError: Cannot read property 'toObject' of null
    at projectModel.handleEnvNullData (/yapi/vendors/server/models/project.js:85:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async interfaceController.autoAddTag (/yapi/vendors/server/controllers/interface.js:396:25)
    at async interfaceController.up (/yapi/vendors/server/controllers/interface.js:825:5)
    at async /yapi/vendors/server/utils/commons.js:436:9
    at async module.exports (/yapi/vendors/server/middleware/mockServer.js:152:15)

解决的方法是: server/models/project.js:83 修改为

handleEnvNullData(data){
    if (data == null) {
      return false;
    }
    data = data.toObject();
    data.toObject = ()=> data;

添加了

if (data == null) {
      return false;
    }

不知道大佬们有没有更好的解决办法~

先生真乃神人也 解决了

@TuringZhu
Copy link

先生真乃神人也 解决了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants