fix(acadenice): filter undefined pageIds before sql.lit() in graph — Patch 030
loadPageMeta logged 'invalid immediate value undefined' on every graph request. Cause: when an edge row has a null source/target_page_id (rare, but happens during partial backlink reindex), the resulting finalPageIds set carries undefined entries, and sql.lit(undefined) rejects. Filter cleanIds to string-only and return early if empty. The catch block stays as a safety net for unrelated SQL errors. Verified via curl: GET /api/acadenice/graph now returns 200 with no ERROR log line. Patch 030.
This commit is contained in:
parent
243168a3f8
commit
3af579498b
1 changed files with 9 additions and 2 deletions
|
|
@ -424,10 +424,17 @@ export class GraphService {
|
||||||
pageIds: string[],
|
pageIds: string[],
|
||||||
spaceId: string | undefined,
|
spaceId: string | undefined,
|
||||||
): Promise<PageMetaRow[]> {
|
): Promise<PageMetaRow[]> {
|
||||||
if (pageIds.length === 0) return [];
|
// Filter out undefined / null / empty entries before binding — sql.lit
|
||||||
|
// throws "invalid immediate value undefined" otherwise. Edges with a
|
||||||
|
// missing source/target page id would surface here when finalPageIds is
|
||||||
|
// assembled from raw rows.
|
||||||
|
const cleanIds = pageIds.filter(
|
||||||
|
(id): id is string => typeof id === 'string' && id.length > 0,
|
||||||
|
);
|
||||||
|
if (cleanIds.length === 0) return [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const idList = sql.join(pageIds.map((id) => sql.lit(id)));
|
const idList = sql.join(cleanIds.map((id) => sql.lit(id)));
|
||||||
const spaceFilter = spaceId ? sql`AND sp.id = ${spaceId}` : sql``;
|
const spaceFilter = spaceId ? sql`AND sp.id = ${spaceId}` : sql``;
|
||||||
|
|
||||||
const rows = await sql<PageMetaRow>`
|
const rows = await sql<PageMetaRow>`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue