Skip to content

fix(core): reject versions and dates it can't read, and skip duplicate versions - #160

Open
botandbang wants to merge 1 commit into
mainfrom
bnb/core-unreadable-input
Open

botandbang wants to merge 1 commit into
mainfrom
bnb/core-unreadable-input

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

Closes #154. Part of #153: these are the cases its properties found that change core's behavior. The rest of #153's properties pass on main and are in the test PR.

Changed:

  • core rejects with an error naming the version and the index URL when index.json has a version that semver.coerce can't read (null, a string with no digits, an object). It used to reject with TypeError: Cannot read properties of null (reading 'major') from core/index.js#L139, and the comment above it said this couldn't happen.
  • core rejects before fetching anything when now isn't an ISO 8601 date or a valid DateTime, with an error naming it. An unreadable now, including a JavaScript Date, used to leave every release line's phases.current as {} with no error.
  • When index.json lists a version twice (say v1.0.0 and then 1.0.0), core keeps the first entry and skips the rest. Before, the later, older entry overwrote the release and the version showed up twice in security.all.
  • The core docs page and the JSDoc on nodevu() say when it rejects, and the line.releases docs say the first entry wins. core/types/index.d.ts is regenerated from the JSDoc.

Added:

  • Two fast-check properties in core/test/errors.js. One puts an unreadable version anywhere in a generated index and checks core names it in a plain Error, not a TypeError. The other generates a now luxon can't read (strings, Dates, an invalid DateTime) and checks core names it without calling fetch. Both failed on main, shrinking to version: null and now: " ".
  • core/test/duplicates.js, which inserts repeats of generated versions after their first entry, some without the v and with different fields, and checks the result equals core's result on the index without them. It failed on main.

The existing example in errors.js passes either way, since it only checks that core rejects.

@botandbang
botandbang requested a review from bnb as a code owner November 14, 2026 23:52

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core throws a TypeError when index.json has a version semver can't read

1 participant