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

オープン 初心者向け
#154 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, node.js
領域
api, backend

調査の方向性

core/index.js の131~139行あたりから始めてください。そこではバージョンが型変換され、その major プロパティが読み取られています。次に core/test/errors.js と issue 内の fixture-server による再現例を確認してください。null などの不正なバージョンが、バージョンと index URL を示すエラーで拒否されるようにし、そのメッセージを検証するようテストを更新してください。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
15
フォーク
2
平均マージ
1日 1時間
マージ済み PR(30日)
60

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cutenode/nodevu のほかの issue

cutenode/nodevu の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。