toeverything/AFFiNE · error

[docs-search] skipped malformed references

Error message

[docs-search] skipped malformed references

What it means

Warning logged in `watchRefsBySourceFrom` when, after scanning indexed reference fields, some entries were malformed — `parseIndexedReferences` reported `malformed > 0` or nodes lacked a valid docId field. The corrupted reference entries are excluded from the refsBySource map; indexing proceeds with the well-formed ones.

Source

Thrown at packages/frontend/core/src/modules/docs-search/services/docs-search.ts:312

              string,
              Map<string, { docId: string } & ReferenceParams>
            >();
            for (const node of nodes) {
              const sourceId = stringField(node.fields.docId);
              const parsed = parseIndexedReferences(node.fields.ref);
              malformed += parsed.malformed;
              if (!sourceId || !docIds.includes(sourceId)) continue;
              let sourceRefs = refsBySource.get(sourceId);
              if (!sourceRefs) {
                sourceRefs = new Map();
                refsBySource.set(sourceId, sourceRefs);
              }
              for (const ref of parsed.refs) {
                if (ref.docId !== sourceId) sourceRefs.set(ref.docId, ref);
              }
            }
            if (malformed > 0) {
              console.warn('[docs-search] skipped malformed references', {
                count: malformed,
              });
            }

            return new Map(
              docIds.map(sourceId => [
                sourceId,
                Array.from(refsBySource.get(sourceId)?.values() ?? []).flatMap(
                  ref => {
                    const doc = this.docsService.list.doc$(ref.docId).value;
                    if (!doc) return [];
                    const params = omit(ref, ['docId']);
                    return [
                      {
                        title: doc.title$.value,
                        docId: doc.id,
                        params: isEmpty(params)
                          ? undefined

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Fix or remove the malformed references in the doc.
  2. Re-index after correcting the reference data.
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when the docs-search indexer parses stored reference data and finds entries that fail validation, skipping those malformed references while building the backlink map.

Common situations: Occurs when indexed doc-link data is corrupted or written by an incompatible version. Backlinks may be incomplete; reindexing the docs usually resolves it.

Understand the failure class


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/fcdfc8a384e03c5a. Report an issue: GitHub.