{"record":{"id":"095b1bd3ec4e253a","repo":"linshenkx/prompt-optimizer","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"APIError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/llm/adapters/openai-adapter.ts","lineNumber":187,"sourceCode":"      // 连接错误处理（包括跨域检测）\n      if (error.message && (error.message.includes('Failed to fetch') ||\n          error.message.includes('Connection error'))) {\n        const isCrossOriginError = this.detectCrossOriginError(error, baseURL)\n\n        if (isCrossOriginError) {\n          throw new APIError(`Cross-origin connection failed: ${error.message}`)\n        } else {\n          throw new APIError(`Connection failed: ${error.message}`)\n        }\n      }\n\n      // API返回的错误信息\n      if (error.response?.data) {\n        throw new APIError(`API error: ${JSON.stringify(error.response.data)}`)\n      }\n\n      // 其他错误,保持原始信息\n      throw new APIError(error.message || 'Unknown error')\n    }\n  }\n\n  // ===== 参数定义（用于buildDefaultModel） =====\n\n  /**\n   * 获取参数定义\n   * 基于 OpenAI 官方文档: https://platform.openai.com/docs/api-reference/chat/create\n   */\n  protected getParameterDefinitions(_modelId: string): readonly ParameterDefinition[] {\n    return [\n      {\n        name: 'reasoning_effort',\n        labelKey: 'params.reasoning_effort.label',\n        descriptionKey: 'params.reasoning_effort.description',\n        description: 'Reasoning effort for GPT-5.6 models.',\n        type: 'string',\n        defaultValue: 'none',","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/llm/adapters/openai-adapter.ts#L169-L205","documentation":"Terminal fallback in getModelsAsync's catch chain: the caught error had no recognizable message (falsy error.message), no response data, and no network markers, so the adapter throws APIError('Unknown error'). It usually indicates an exception thrown by something other than the HTTP call itself.","triggerScenarios":"A bug or non-Error throw inside the try block (undefined variable, JSON parse of unexpected input that throws without message), SDK internals throwing empty errors, or aborted requests in some runtimes.","commonSituations":"Runtime/edge-case bugs in adapter code paths, aborted fetches in tests, objects thrown instead of Error.","solutions":["Reproduce with verbose logging around the getModelsAsync call to find what was actually thrown","Upgrade the core package in case the empty-message bug was fixed","Wrap call sites to log the raw caught value (not just .message)","File an issue with the stack trace if it originates inside the adapter"],"exampleFix":"// before\ncatch (e: any) { throw new APIError(e.message || 'Unknown error') }\n\n// after\ncatch (e: any) {\n  console.error('raw error:', e)\n  throw new APIError(e?.message || e?.toString() || 'Unknown error')\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { models = await adapter.getModelsAsync() }\ncatch (e) {\n  if (e instanceof APIError && e.message === 'Unknown error') { captureRawErrorDiagnostics(); models = [] }\n  else throw e\n}","preventionTips":["Log the raw thrown value, not just .message, at call sites","Keep the core package updated","Add integration tests covering model listing for each provider"],"tags":["openai","unknown-error","diagnostics"],"backgroundTag":"unknown-runtime-error","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}