Repository navigation
fix(validate): type-check list and boolean fields and strip trailing comments in scalars - #128
Closed
rahul05ranjan wants to merge 2 commits into
Closed
rahul05ranjan wants to merge 2 commits into
rahul05ranjan wants to merge 2 commits into
Conversation
…es as problems --stale-days given as the last argument or as a non-number became NaN and the run died in new Date(NaN).toISOString() only after every fetch had already run. A GitHub API 5xx/timeout/rate limit was written as a row under 'repository state differs from maintenance' and counted in problems, so a transient outage opened the correction issue; after a 403/429 the loop broke and the remaining repositories were silently unchecked. The flag is now validated before anything runs, API failances land in a 'Could not check (N skipped)' section excluded from problems, and a rate-limited loop says which repositories were not checked and why. The helpers moved to lib/link-check.mjs so the argument parsing and the failure classification are tested. Fixes TMHSDigital#82 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
…ments in scalars The validator checked list fields for emptiness but never that they are lists, and never that commercial/attribution_required are booleans. The frontmatter parser had no trailing-comment handling, so the template's own 'tags: [low-poly, modular] # ...' line parsed as a string and every new entry from npm run new-entry that kept the comment started with string tags; a quoted commercial: "true" passed the enum check and rendered as 'commercial ?'. parseScalar now strips unquoted trailing comments (a # preceded by whitespace, outside quotes; URL fragments untouched), and validate rejects non-list lists and non-boolean boolean fields via two new checks in checks.mjs. Fixes TMHSDigital#79 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Owner
|
Thank you for this, and for the tests. #124 merged this morning with the same fix for #79 (opened before this PR could be reviewed), so this branch now conflicts with main and the issue is closed. I compared the two line by line and main covers everything here, so I am closing this as superseded rather than asking for a rebase. Contributions are welcome on any of the remaining open issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #79
What changed
The parser now strips an unquoted trailing
# comment(site/lib/frontmatter.mjs,parseScalar): a#preceded by whitespace and outside quotes ends the value, exactly as YAML reads it. So the template's own linenow parses as the list
["low-poly", "modular"]instead of the string"[low-poly, modular] # describe the content…". A#inside quotes and a URL fragment with no space before it (https://example.com/#anchor) are kept. Comments stay encouraged in entries — only the value parsing changed. Because of this, every new entry fromnpm run new-entrythat keeps the template's comments no longer starts life with stringtags; no scaffold change was needed.The validator now type-checks the shapes (
site/checks.mjs, wired insite/validate.mjs):checkListTypes:subcategories,formats,tags,hardware_tagsmust be lists when present. A string like the old mangledtagsis an error instead of silently falling back to[]everywhere downstream.checkBooleanField:commercialmust be boolean orunknown|varies;attribution_requiredmust be boolean orunknown. A quoted"true"is rejected as the string it is, instead of passing the enum check and rendering as "commercial ?" on the card.Per the issue's evidence, no committed entry is affected — this is a trap for the next contributor, now closed at both ends (parser + validator).
Verification (system Node v26.12.1, no installs)
node site/lib/lib.test.mjs: 434 ok (425 before; 9 new — URL fragment kept, comment stripped from a flow list and from a boolean, quoted#kept, strip only outside quotes, no-space#kept, and the template's own tags line parses as a list with zero parser errors).node site/checks.test.mjs: 144 ok (134 before; 10 new — stringtags/formatsrejected, list and absent and empty-list pass, quoted"true"/"false"rejected for both fields,varies/unknownpass).node site/validate.mjson the full catalog: exit 0, no errors — all 415 committed entries pass the new checks, matching the issue's audit.node --checkon all changed files: OK.AI-assisted implementation and self-review.