{"record":{"id":"6662c1a31a7c502b","repo":"ZhuLinsen/daily_stock_analysis","slug":"desktop-share-image-capture-returned-an-empty-imag","errorCode":null,"errorMessage":"Desktop share image capture returned an empty image","messagePattern":"Desktop share image capture returned an empty image","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/dsa-desktop/main.js","lineNumber":1445,"sourceCode":"      || !Number.isFinite(pageMetrics.height)\n      || pageMetrics.height < 1\n      || pageMetrics.height > DESKTOP_SHARE_IMAGE_MAX_HEIGHT\n    ) {\n      throw new Error(`Desktop share image has invalid dimensions: ${pageMetrics.width}x${pageMetrics.height}`);\n    }\n\n    renderWindow.setContentSize(DESKTOP_SHARE_IMAGE_WIDTH, pageMetrics.height);\n    await renderWindow.webContents.executeJavaScript(\n      'new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))'\n    );\n    const image = await renderWindow.webContents.capturePage({\n      x: 0,\n      y: 0,\n      width: DESKTOP_SHARE_IMAGE_WIDTH,\n      height: pageMetrics.height,\n    });\n    if (!image || image.isEmpty()) {\n      throw new Error('Desktop share image capture returned an empty image');\n    }\n\n    const png = image.toPNG();\n    return png.buffer.slice(png.byteOffset, png.byteOffset + png.byteLength);\n  } finally {\n    if (renderWindow && !renderWindow.isDestroyed()) {\n      renderWindow.destroy();\n    }\n  }\n}\n\nfunction isWindowsNsisInstalledApp() {\n  if (!isWindows || !app.isPackaged) {\n    return false;\n  }\n\n  const appDir = path.dirname(app.getPath('exe'));\n  return fs.existsSync(path.join(appDir, 'Uninstall Daily Stock Analysis.exe'));","sourceCodeStart":1427,"sourceCodeEnd":1463,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/apps/dsa-desktop/main.js#L1427-L1463","documentation":"Raised by PortfolioService.query_corporate_actions when the action_type filter, after strip+lowercase, is not in VALID_CORPORATE_ACTIONS = {'cash_dividend','split_adjustment'} (portfolio_service.py:38). Enforced before the repository query.","triggerScenarios":"GET /portfolio/corporate-actions?action_type=dividend, ?action_type=split, ?action_type=merger, or the direct call with those values. 'CASH_DIVIDEND' works (lowercased); blank means no filter. The exact literals 'cash_dividend' and 'split_adjustment' (underscore) are required.","commonSituations":"Users typing the natural words 'dividend' or 'split' without the prefix/underscore; clients ported from systems whose action enums include mergers, spinoffs, or stock dividends that this service does not support yet; typo 'cash-dividend' with a hyphen.","solutions":["Use exactly 'cash_dividend' or 'split_adjustment' (case-insensitive, underscore separator)","Omit action_type to list both kinds","Map friendly labels to the enum in the UI layer ('Dividend' -> 'cash_dividend')","Restrict the client-side enum so other values cannot be sent"],"exampleFix":"# before\nsvc.query_corporate_actions(action_type=\"split\")\n# after\nsvc.query_corporate_actions(action_type=\"split_adjustment\")","handlingStrategy":"validation","validationCode":"VALID_CORPORATE_ACTIONS = {\"cash_dividend\", \"split_adjustment\"}\n\ndef action_type_ok(action_type):\n    return action_type is None or not action_type.strip() or action_type.strip().lower() in VALID_CORPORATE_ACTIONS","typeGuard":"from typing import Literal, TypeGuard\n\nCorpActionType = Literal[\"cash_dividend\", \"split_adjustment\"]\n\ndef is_corp_action_type(value: str) -> TypeGuard[CorpActionType]:\n    return value.strip().lower() in {\"cash_dividend\", \"split_adjustment\"}","tryCatchPattern":"try:\n    svc.query_corporate_actions(action_type=a)\nexcept ValueError as exc:\n    if \"action_type must be\" in str(exc):\n        raise HTTPBadRequest(detail=str(exc)) from exc\n    raise","preventionTips":["Remember the underscore form: cash_dividend, split_adjustment","Map friendly labels ('Dividend', 'Split') in the UI layer","Only two action types exist; other corporate events are unsupported"],"tags":["portfolio","validation","enum","corporate-action"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}