Skip to content

bug: lint aborts whole tree on numeric/missing frontmatter title (opts.title.toLowerCase is not a function) #1883

@garrytan-agents

Description

@garrytan-agents

Problem

gbrain lint aborts the entire pass with opts.title.toLowerCase is not a function when it hits a page whose frontmatter title is a purely numeric value that YAML parses as a number instead of a string.

companies/222.md:
opts.title.toLowerCase is not a function. (In 'opts.title.toLowerCase()', 'opts.title.toLowerCase' is undefined)

Because the crash is unguarded, lint stops early and never scans the rest of the tree — on a 209K-page brain it was silently aborting after a few thousand pages, so doctor's lint count and all downstream lint-fix automation were running on a fraction of the corpus.

Root cause

A page with frontmatter like:

---
type: company
title: 222
---

YAML parses title: 222 as the number 222, not the string "222". The lint code calls opts.title.toLowerCase() assuming it's always a string. Numbers (and missing titles → undefined) both throw.

Confirmed on 3 real pages in a production brain: titles 222, 8189165238, 1458 (the latter two are date-stamped note filenames that became numeric titles).

Fix

Coerce defensively before .toLowerCase():

const title = String(opts.title ?? '').toLowerCase();

Or normalize at frontmatter-parse time: always cast title to a string. A numeric or missing title should never crash a full-tree maintenance pass — at worst it's a lint finding (e.g. "title should be quoted"), not a hard abort.

Severity

Medium-high: silent. The pass exits 0 and prints partial results, so nothing signals that 95% of the brain went unscanned. Any brain with a single numeric-title page has been getting incomplete lint + doctor lint counts.

Environment

  • gbrain 0.42.26.0
  • 209,481-page brain; aborted early until the 3 numeric-title pages were manually quoted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions