{"record":{"id":"45da2f51d0b8afe8","repo":"ZhuLinsen/daily_stock_analysis","slug":"desktop-share-image-has-invalid-dimensions-page","errorCode":null,"errorMessage":"Desktop share image has invalid dimensions: ${pageMetrics.width}x${pageMetrics.height}","messagePattern":"Desktop share image has invalid dimensions: (.+?)x(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/dsa-desktop/main.js","lineNumber":1431,"sourceCode":"    });\n\n    await renderWindow.loadURL(targetUrl);\n    const pageMetrics = await renderWindow.webContents.executeJavaScript(`({\n      contentType: document.contentType,\n      width: Math.ceil(Math.max(document.documentElement.scrollWidth, document.body.scrollWidth)),\n      height: Math.ceil(Math.max(document.documentElement.scrollHeight, document.body.scrollHeight))\n    })`);\n    if (!pageMetrics || pageMetrics.contentType !== 'text/html') {\n      throw new Error('Desktop share image source did not return HTML');\n    }\n    if (\n      !Number.isFinite(pageMetrics.width)\n      || pageMetrics.width !== DESKTOP_SHARE_IMAGE_WIDTH\n      || !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);","sourceCodeStart":1413,"sourceCodeEnd":1449,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/apps/dsa-desktop/main.js#L1413-L1449","documentation":"Raised by PortfolioService.query_corporate_actions when a non-blank symbol filter normalizes to nothing. Same mechanism as the trades symbol filter: _build_symbol_filter_values returns an empty list and the service raises rather than silently querying all symbols.","triggerScenarios":"GET /portfolio/corporate-actions?symbol=%%%, ?symbol=___, or query_corporate_actions(symbol=\"???\") where canonical_stock_code/normalize_stock_code return ''. Whitespace-only symbol bypasses the filter entirely (no error).","commonSituations":"Searching corporate actions by a company name ('Kweichow Moutai') instead of a ticker; symbols corrupted by encoding issues; CSV-sourced filters containing dashes or dots only.","solutions":["Pass a ticker in a supported format ('600519', 'SH600519', '00700.HK', 'AAPL')","Drop the symbol parameter if you intend to list actions across all symbols","Pre-validate filter input with data_provider.base.canonical_stock_code and reject empties in the UI","Trim and sanity-check symbols coming from spreadsheets before they reach the API"],"exampleFix":"# before\nsvc.query_corporate_actions(symbol=\"---\")\n# after\nsvc.query_corporate_actions(symbol=\"600519\")","handlingStrategy":"validation","validationCode":"from data_provider.base import canonical_stock_code\n\ndef corp_action_symbol_ok(symbol):\n    if symbol is None or not symbol.strip():\n        return True\n    return bool(canonical_stock_code(symbol.strip()))","typeGuard":"def is_queryable_symbol(symbol: str | None) -> bool:\n    if not (symbol or \"\").strip():\n        return True  # no filter\n    return bool(canonical_stock_code(symbol))","tryCatchPattern":"try:\n    svc.query_corporate_actions(symbol=s)\nexcept ValueError as exc:\n    if \"symbol is invalid\" in str(exc):\n        return {\"items\": [], \"total\": 0}\n    raise","preventionTips":["Search by ticker, not company name","Validate symbols with canonical_stock_code before sending","Strip spreadsheet artifacts (dashes, dots-only) from filter inputs"],"tags":["portfolio","validation","symbol","corporate-action"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}