ZhuLinsen/daily_stock_analysis · warning · Error
Desktop window is unavailable
Error message
Desktop window is unavailable
What it means
Raised by PortfolioService.query_cash_ledger when the direction filter, after strip+lowercase, is not in VALID_CASH_DIRECTIONS = {'in','out'} (portfolio_service.py:37). Checked before repo.query_cash_ledger executes.
Source
Thrown at apps/dsa-desktop/main.js:1384
throw new Error('Desktop share images require the configured backend origin');
}
return new URL(
`/api/v1/history/${recordId}/share-image-html`,
page.origin
).toString();
}
async function renderDesktopShareImage(
recordId,
{
sourceWindow = mainWindow,
BrowserWindowClass = BrowserWindow,
backendOrigin = '',
} = {}
) {
if (!sourceWindow || sourceWindow.isDestroyed() || !sourceWindow.webContents) {
throw new Error('Desktop window is unavailable');
}
const targetUrl = buildDesktopShareImageUrl(
sourceWindow.webContents.getURL(),
recordId,
backendOrigin
);
let renderWindow = null;
try {
renderWindow = new BrowserWindowClass({
show: false,
width: DESKTOP_SHARE_IMAGE_WIDTH,
height: DESKTOP_SHARE_IMAGE_INITIAL_HEIGHT,
...(isMac ? { enableLargerThanScreen: true } : {}),
useContentSize: true,
backgroundColor: '#eef4fd',
webPreferences: {
nodeIntegration: false,View on GitHub (pinned to 5159bd72e8)
Solutions
- Use exactly 'in' or 'out' (case-insensitive)
- Omit the parameter for an unfiltered ledger query
- Map broker vocabulary (deposit->in, withdrawal->out) in an adapter layer before calling
- Pin the valid values in the API client schema so invalid states are unrepresentable
Example fix
# before svc.query_cash_ledger(direction="deposit") # after svc.query_cash_ledger(direction="in")
Defensive patterns
Strategy: validation
Validate before calling
VALID_CASH_DIRECTIONS = {"in", "out"}
def direction_ok(direction):
return direction is None or not direction.strip() or direction.strip().lower() in VALID_CASH_DIRECTIONS Type guard
from typing import Literal, TypeGuard
CashDirection = Literal["in", "out"]
def is_cash_direction(value: str) -> TypeGuard[CashDirection]:
return value.strip().lower() in {"in", "out"} Try / catch
try:
svc.query_cash_ledger(direction=d)
except ValueError as exc:
if "direction must be in or out" in str(exc):
raise HTTPBadRequest(detail=str(exc)) from exc
raise Prevention
- Pin the client enum to in/out; reject debit/credit synonyms at the edge
- Map deposit/withdraw vocabulary in an adapter layer
- Empty string means 'no filter', not 'all' — decide deliberately
When it happens
Trigger: GET /portfolio/cash-ledger?direction=deposit, ?direction=inflow, ?direction=IN%2FOUT, or query_cash_ledger(direction="credit"). 'IN'/'Out' pass due to lowercasing; empty/whitespace means no filter.
Common situations: Clients modeling cash movement with debit/credit or deposit/withdraw vocabulary instead of in/out; enum mismatch after importing data from broker exports; frontend select options not updated to the service contract.
Related errors
- Desktop backend origin is invalid
- Desktop share images require the configured backend origin
- Desktop share image capture returned an empty image
- 请提供文件或粘贴文本
- Backend executable not found: ${backendPath}
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/0c82cb0d25cb19a1.
Report an issue: GitHub.