ZhuLinsen/daily_stock_analysis · warning · Error
Desktop share image capture returned an empty image
Error message
Desktop share image capture returned an empty image
What it means
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.
Source
Thrown at apps/dsa-desktop/main.js:1445
|| !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);
} finally {
if (renderWindow && !renderWindow.isDestroyed()) {
renderWindow.destroy();
}
}
}
function isWindowsNsisInstalledApp() {
if (!isWindows || !app.isPackaged) {
return false;
}
const appDir = path.dirname(app.getPath('exe'));
return fs.existsSync(path.join(appDir, 'Uninstall Daily Stock Analysis.exe'));View on GitHub (pinned to 5159bd72e8)
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
Example fix
# before svc.query_corporate_actions(action_type="split") # after svc.query_corporate_actions(action_type="split_adjustment")
Defensive patterns
Strategy: validation
Validate before calling
VALID_CORPORATE_ACTIONS = {"cash_dividend", "split_adjustment"}
def action_type_ok(action_type):
return action_type is None or not action_type.strip() or action_type.strip().lower() in VALID_CORPORATE_ACTIONS Type guard
from typing import Literal, TypeGuard
CorpActionType = Literal["cash_dividend", "split_adjustment"]
def is_corp_action_type(value: str) -> TypeGuard[CorpActionType]:
return value.strip().lower() in {"cash_dividend", "split_adjustment"} Try / catch
try:
svc.query_corporate_actions(action_type=a)
except ValueError as exc:
if "action_type must be" in str(exc):
raise HTTPBadRequest(detail=str(exc)) from exc
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Backend executable not found: ${backendPath}
- Desktop backend origin is invalid
- Desktop window is unavailable
- Desktop share image source did not return HTML
- Desktop share image has invalid dimensions: ${pageMetrics.wi
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/6662c1a31a7c502b.
Report an issue: GitHub.