Fix: loader coerces blank numeric frontmatter to 0 instead of documented defaults
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #559 by @Kuldeep2822k — merged
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with the numeric parsers in src/storage/loader.ts and compare their blank string handling with parseScore, then read the documented defaults in docs/05-1-topic-and-assessment-schema.md. Update the tests in test/storage-loader.test.ts to cover blank numeric fields. Done when blank values load as the stated defaults, including last_quality as null.
Written by the indexing model from the issue text.
Description
Loader coerces blank numeric frontmatter fields to 0 instead of documented defaults
This is subtle and easy to miss. If a topic note has interval_days: "" (empty
string, maybe from a botched manual edit or a YAML quirk), the loader silently
turns it into 0 instead of the documented default of 1. Same for
ease_factor → 0 instead of 2.5, and last_quality → 0 instead of
null.
The difference matters: last_quality: 0 means "reviewed, quality 0" while
last_quality: null means "never reviewed." The loader is turning the latter
into the former.
Reproduction
# Edit a topic note to have blank numeric fields:
# interval_days: ""
# ease_factor: ""
# last_quality: ""
palee next --json
# The topic loads with mastery 0.0 instead of using defaults
Root cause
src/storage/loader.ts:
parseScore(line 145-153) does guard blank strings:if (trimmed) { return Number(trimmed); } return fallback;- But
parseInteger(line 180-182),parseOptionalInteger(212-214), and
parseNumber(240-242) do not:return Number(val.trim()); // Number('') === 0
Call sites at loader.ts:386-390 pass fallbacks (2.5 for ease_factor, 1 for
interval_days, 0 for repetition, null for last_quality), but the unguarded
parsers return 0 for empty strings before the fallback is ever consulted.
parseOptionalInteger's own docstring (loader.ts:189-191) says it exists to
preserve the SM-2 "no value yet" state as null — a blank string defeats that
intent, becoming quality 0 instead.
ADR / convention
docs/05-1-topic-and-assessment-schema.md:86 (ease_factor default 2.5) and
:154-158 (adopt shape: ease_factor 2.5, interval_days 1, last_quality null).
src/validation/rules/valid-review-fields.ts:18,58 defines the contract:
"last_quality: null, or an integer 0-5" and "never-reviewed = null, else
integer 0-5."
Acceptance criteria
parseInteger/parseOptionalInteger/parseNumberguard blank strings the
same wayparseScoredoes.- A topic note with
interval_days: ""loads as1(default), not0. - A topic note with
last_quality: ""loads asnull(never reviewed), not
0(reviewed, quality 0). - Test in
test/storage-loader.test.ts: blank-string fields resolve to their
documented defaults.
I did not use AI to generate this issue report.
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 17h 46m
- Merged PRs (30d)
- 170
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Kuldeep2822k/cli
-
bug core priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Kuldeep2822k/cli#343 · 1 comment ·
Maintainers usually reply within 1 day
-
Task: Full-repository improvement audit at 24947bc — verified P1/P2/P3 remediation checklistPossibly taken @Kuldeep2822k claimed this 3 days ago. Openchore ci cli core dependencies P1 security storage tests
Kuldeep2822k/cli#565 · 2 comments · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
chore priority: low refactor
Difficulty 5/5 Over a week Newbie friendliness 25/100
Kuldeep2822k/cli#548 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Kuldeep2822k/cli#522 ·
Maintainers usually reply within 1 day
-
bug tests
Difficulty 5/5 Over a week Newbie friendliness 25/100
Kuldeep2822k/cli#504 ·
Maintainers usually reply within 1 day
All issues in Kuldeep2822k/cli
Similar issues
-
area: frontend priority: normal
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
formbricks/formbricks#9918 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
thecodacus/pithagoras#364 ·
Maintainers usually reply within 1 day
-
TestAutonomousStop_ReportsObservedState fails under host load: 1s wall-clock ceiling vs 250ms cycleOpentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
nightgauge/nightgauge#2909 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day