{"record":{"id":"89c9a5ed66b9c3c2","repo":"YMFE/yapi","slug":"error-89c9a5","errorCode":null,"errorMessage":"还没有生成报告","messagePattern":"还没有生成报告","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js","lineNumber":508,"sourceCode":"  }\n\n  // 测试用例环境面板折叠\n  changeCollapseClose = key => {\n    if (key) {\n      this.setState({\n        collapseKey: key\n      });\n    } else {\n      this.setState({\n        collapseKey: '1',\n        currColEnvObj: {}\n      });\n    }\n  };\n\n  openReport = id => {\n    if (!this.reports[id]) {\n      return message.warn('还没有生成报告');\n    }\n    this.setState({ visible: true, curCaseid: id });\n  };\n\n  openAdv = id => {\n    let findCase = _.find(this.props.currCaseList, item => item.id === id);\n\n    this.setState({\n      enableScript: findCase.enable_script,\n      curScript: findCase.test_script,\n      advVisible: true,\n      curCaseid: id\n    });\n  };\n\n  handleScriptChange = d => {\n    this.setState({ curScript: d.text });\n  };","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/YMFE/yapi/blob/59bade3a8a43e7db077d38a4b0c7c584f30ddf8c/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js#L490-L526","documentation":"openReport in InterfaceColContent.js shows an Ant Design warning when no test report exists for the given case id in the component's in-memory this.reports map. Reports are only populated after a test run completes in the current session, so opening one prematurely warns 'report not generated yet'.","triggerScenarios":"Clicking the 'open report' action for a case before running it, after a page refresh (this.reports is reset, not persisted), or for a case whose run failed before producing a report.","commonSituations":"User expects reports to persist across reloads; automated script triggers openReport without first invoking the test run; report generation failed server-side so this.reports[id] was never set.","solutions":["Run the test case/col first so a report is generated, then open the report","Persist reports (server-side or localStorage) if they must survive page refreshes","Check the test-run request for failures that prevented the report from being stored in this.reports","Catch/verify this.reports[id] exists before navigating to the report view"],"exampleFix":"// before\nopenReport = id => {\n  this.setState({ visible: true, curCaseid: id });\n};\n// after\nopenReport = id => {\n  if (!this.reports[id]) {\n    return message.warn('还没有生成报告，请先运行测试');\n  }\n  this.setState({ visible: true, curCaseid: id });\n};","handlingStrategy":"type-guard","validationCode":"const openReportIfReady = id => {\n  if (this.reports && this.reports[id]) this.openReport(id);\n  else message.warn('Run the test first to generate a report');\n};","typeGuard":"function hasReport(reports, id){ return Boolean(reports) && Object.prototype.hasOwnProperty.call(reports, id) && !!reports[id]; }","tryCatchPattern":"// component-level guard before opening\nif (!hasReport(this.reports, id)) return; // avoid setState on missing report","preventionTips":["Disable the 'open report' button until a run has completed for the case","Persist reports to the server/localStorage so they survive page refreshes","Handle failed test runs so reports map entries are not silently skipped","Write integration tests covering open-before-run flows"],"tags":["ui","react","test-report"],"backgroundTag":"report-not-found","analyzedSha":"59bade3a8a43e7db077d38a4b0c7c584f30ddf8c","analyzedAt":"2026-08-29T08:45:22.203Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}