Skip to content

validate: list and boolean fields are never type-checked; a trailing # comment turns tags into a string and the template ships one #79

Closed

Description

@TMHSDigital

Why it matters
The validator is the catalog's only guard. It checks list fields for emptiness but never that they are lists, and never that commercial / attribution_required are booleans. The frontmatter parser has no trailing-comment handling, so tags: [a, b] # note parses to the string "[a, b] # note". catalog/TEMPLATE.md ships exactly that line, and the scaffold only strips comments from verified and status, so every new entry created with npm run new-entry that keeps the comment starts with a string tags. Every downstream check does Array.isArray(x) ? x : [], so the entry passes validation and is built with no tags (search and the chip filters miss it). Likewise commercial: "true" passes the enum check as the string "true" and renders on the card as "commercial ?".

Evidence (all reproduced on 2026-10-21)

  • site/lib/frontmatter.mjs:38-51 parseScalar: no comment stripping. parseFrontmatter("---\ntags: [a, b] # note\ncommercial: \"true\"\n---") → tags: "[a, b] # note", commercial: "true" (string).
  • catalog/TEMPLATE.md:14 tags: [low-poly, modular] # describe the content; never the licence or the publisher (V19, V21).
  • site/lib/scaffold.mjs:~136 newEntryText strips comments only from verified/status.
  • site/validate.mjs:269 list fields checked for emptiness only; site/checks.mjs:292, 334, 447 fall back to [] on non-arrays; site/build.mjs:98-99 ships the fallback; build.mjs:84-91 maps a non-boolean commercial to "unknown".
  • site/validate.mjs:286-302 enumKey accepts the string "true" because it is in the allowed set.
  • Today no committed entry is affected (checked all 414), so this is a trap for the next contributor rather than live damage.

Suggested approach

  1. parseScalar: strip #... outside quotes (or report a line error), with tests for inline lists, quoted strings containing #, and bare scalars.
  2. validate.mjs: require Array.isArray for subcategories, formats, tags (and hardware_tags, ue_versions); require typeof v === "boolean" or the literal varies/unknown for commercial and attribution_required; reject quoted booleans with a message that names the fix.
  3. Drop the inline comments from TEMPLATE.md (move the guidance to the comment lines above) or make newEntryText strip them from every field.
  4. Add fixtures to checks.test.mjs for each case.

Done when
A string tags or a quoted boolean fails npm run validate with a clear message, the template round-trips through the scaffold to a valid entry, and the parser tests cover trailing comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions