Skip to content

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

Closed

Description

@botandbang

When index.json has a version that semver.coerce can't read (null, a string with no digits, an object), core rejects with TypeError: Cannot read properties of null (reading 'major') from core/index.js#L139. The comment above it at L131 assumes every version parses, so nothing checks for null.

The error doesn't say which entry or which URL was the problem, and core/test/errors.js only checks that core rejects, so the TypeError passes it.

Repro, with the fixture server:

const nodevu = require('@nodevu/core');
const { at } = require('@nodevu/fixtures');

await nodevu(at('2024-01-01', {
  index: [{ version: null, date: '2024-01-01', files: ['src'] }],
  schedule: {},
}));
// TypeError: Cannot read properties of null (reading 'major')

fast-check finds it in its first run, shrunk to version: null in an otherwise empty index.

core should reject with an error that names the version and the index URL instead.

Found while working on #153.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions