ZhuLinsen/daily_stock_analysis · warning · Error
Desktop share image has invalid dimensions: ${pageMetrics.wi
Error message
Desktop share image has invalid dimensions: ${pageMetrics.width}x${pageMetrics.height} What it means
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.
Source
Thrown at apps/dsa-desktop/main.js:1431
});
await renderWindow.loadURL(targetUrl);
const pageMetrics = await renderWindow.webContents.executeJavaScript(`({
contentType: document.contentType,
width: Math.ceil(Math.max(document.documentElement.scrollWidth, document.body.scrollWidth)),
height: Math.ceil(Math.max(document.documentElement.scrollHeight, document.body.scrollHeight))
})`);
if (!pageMetrics || pageMetrics.contentType !== 'text/html') {
throw new Error('Desktop share image source did not return HTML');
}
if (
!Number.isFinite(pageMetrics.width)
|| pageMetrics.width !== DESKTOP_SHARE_IMAGE_WIDTH
|| !Number.isFinite(pageMetrics.height)
|| pageMetrics.height < 1
|| pageMetrics.height > DESKTOP_SHARE_IMAGE_MAX_HEIGHT
) {
throw new Error(`Desktop share image has invalid dimensions: ${pageMetrics.width}x${pageMetrics.height}`);
}
renderWindow.setContentSize(DESKTOP_SHARE_IMAGE_WIDTH, pageMetrics.height);
await renderWindow.webContents.executeJavaScript(
'new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))'
);
const image = await renderWindow.webContents.capturePage({
x: 0,
y: 0,
width: DESKTOP_SHARE_IMAGE_WIDTH,
height: pageMetrics.height,
});
if (!image || image.isEmpty()) {
throw new Error('Desktop share image capture returned an empty image');
}
const png = image.toPNG();
return png.buffer.slice(png.byteOffset, png.byteOffset + png.byteLength);View on GitHub (pinned to 5159bd72e8)
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
Example fix
# before svc.query_corporate_actions(symbol="---") # after svc.query_corporate_actions(symbol="600519")
Defensive patterns
Strategy: validation
Validate before calling
from data_provider.base import canonical_stock_code
def corp_action_symbol_ok(symbol):
if symbol is None or not symbol.strip():
return True
return bool(canonical_stock_code(symbol.strip())) Type guard
def is_queryable_symbol(symbol: str | None) -> bool:
if not (symbol or "").strip():
return True # no filter
return bool(canonical_stock_code(symbol)) Try / catch
try:
svc.query_corporate_actions(symbol=s)
except ValueError as exc:
if "symbol is invalid" in str(exc):
return {"items": [], "total": 0}
raise Prevention
- Search by ticker, not company name
- Validate symbols with canonical_stock_code before sending
- Strip spreadsheet artifacts (dashes, dots-only) from filter inputs
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Backend executable not found: ${backendPath}
- Desktop backend URL is unavailable
- Desktop share image source did not return HTML
- Desktop share image capture returned an empty image
- Invalid share image record ID
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/45da2f51d0b8afe8.
Report an issue: GitHub.