parityHistory query fails with NaN when a parity-checks.log record has an empty errors field
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- graphql, typescript
调研方向
从 api/src/unraid-api/graph/resolvers/array/parity.service.ts 的 getParityHistory() 开始,这里会用 '|' 拆分 parity-checks.log 的每一行,并把 errors 字段传给 Number.parseInt。日期和持续时间已经有防护检查,所以请对 errors 采用同样的模式。复现时,把错误行 1969 Dec 31 17:00:00|0|nan B/s|| 添加到测试日志中,然后运行 parityHistory 查询。当所有记录都能返回,且错误记录的 errors 为 null 或被跳过时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Environment
Unraid OS Version: 7.3.4 (API 4.37.9+bedd403a, kernel 6.18.58-Unraid)
Are you using a reverse proxy? No. Tested directly against the server's built-in /graphql endpoint over the LAN, authenticated with an x-api-key (ADMIN role).
Hardware / setup that may matter: Supermicro X12STH-F, Xeon E-2356G, USB flash boot device, 1 parity + 11 data disks, 2 pools. This install has been upgraded in place since 2018, so /boot/config/parity-checks.log holds 162 records written by many OS versions: 98 in the old 5-field format and 63 in the current 7-field format, plus the bad record below.
Pre-submission Checklist
- I have verified that my Unraid OS is up to date
- I have tested this issue by accessing my server directly (not through a reverse proxy)
- This is not an Unraid Connect related issue (if it is, please submit via the support form instead)
Issue Description
The parityHistory query fails completely if any record in /boot/config/parity-checks.log has an empty errors field. One bad record makes the whole history unavailable.
Our log contained this record, written by the OS in March 2019 (it sits between a 2019-03-13 entry and a 2019-03-29 entry):
1969 Dec 31 17:00:00|0|nan B/s||
The date is Unix time 0 in local time (UTC-7), the duration is 0, the speed is nan B/s, and both the status and errors fields are empty. It looks like an old release logged a check that never actually started.
ParityService.getParityHistory() (api/src/unraid-api/graph/resolvers/array/parity.service.ts, unchanged on main) already guards the date and the duration against bad values, but not the errors field:
const [date, duration, speed, status, errors = '0'] = line.split('|');
...
errors: Number.parseInt(errors, 10),
The = '0' default only applies when the field is missing. Here the field is present but empty, so parseInt('') returns NaN, and GraphQL rejects the whole response because ParityCheck.errors is an Int.
Steps to Reproduce
- Add a record with an empty fifth field to
/boot/config/parity-checks.log, for example1969 Dec 31 17:00:00|0|nan B/s||. - Run
query { parityHistory { date duration speed status errors } }. - The query returns no data.
Expected Behavior
The history is returned. The bad record is either skipped or returned with errors: null (the field is already nullable in the schema), the same way bad dates and durations are already handled.
Actual Behavior
{"errors":[{"message":"Int cannot represent non-integer value: NaN", ...}]}
Removing just that one line from the log (all other 161 records unchanged) makes the same query return all 161 records, which confirms the cause.
Additional Context
Suggested fix, matching the existing duration handling:
const errorsNumber = Number.parseInt(errors, 10);
...
errors: Number.isNaN(errorsNumber) ? undefined : errorsNumber,
Servers that have been upgraded from older releases may carry records like this without knowing it.
- 主要语言
- TypeScript
- 星标
- 123
- 派生
- 25
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
unraid/api 的其他 Issue
-
Temperature metrics: lm-sensors voltages, fan speeds and power are reported as temperatures (°C)未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
flash { guid } always fails: resolver no longer returns guid but the schema marks it non-nullable未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
yavorsky/unbuilt.app#65 ·
-
CVE security
难度 2/5 1-3 小时 新手友好度 68/100
mckinsey/agents-at-scale-ark#4091 · 1 条评论 ·
维护者通常 1 天内回复
-
factory:subtask
难度 1/5 1 小时以内 新手友好度 94/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
NUS-Project-SaBai/project-sabai#386 ·
维护者通常 3 天内回复
-
android needs clarification
难度 2/5 1-3 小时 新手友好度 72/100
super-productivity/super-productivity#12105 · 3 条评论 ·
维护者通常 1 天内回复