A read-only demo of every feature
Every page of this repository is open, and nothing can change. Take a guided tour of what TanStack Source does.
addTask accepts a priority that is not a number #9
Send to my agentOpenAlemTuzlak opened this issue 1 comment
tanstack-source added labelsbug
tanstack-source published a comment(spam 4%, injection 16%)
AlemTuzlak added labelsfactory:fix
AlemTuzlak pinned this issue
Sign in to join this conversation.
Reproduced on
main(8c5e0f6).addTaskaccepts any priority that is not a number, not just negative numbers.What happens#
src/tasks.tsvalidates the priority with a single comparison:The only guard is
if (priority < 0). Every non-number falls through it, because nothing that is not a number compares as< 0:Number.isNaN(NaN)is false,'high' < 0is false ('high'becomes NaN),null < 0is false (nullbecomes 0), and an object or array becomes NaN. The call then succeeds and stores the value in a field typed aspriority: number.Concretely, with
addTask([], 'Docs', 'high'):priority: 'high'.Task.priority(number) and the JSDoc "Lower numbers come first." are violated.openTaskssorts witha.priority - b.priority, so'high' - 1is NaN and the "most important first" order is not kept — a docs task with priority'high'even sorts before a task with priority1.Tested values that are all accepted:
'high','5',NaN,null,true,{ level: 1 }.Suspected files#
src/tasks.ts—addTask: the guardif (priority < 0)does not reject non-numbers; this is the place to fix (for exampleif (typeof priority !== 'number' || !Number.isInteger(priority) || priority < 0) throw ...).test/tasks.test.ts— has a test for a negative priority (refuses a negative priority) but none for a non-number priority.src/tasks.ts—openTasksshows the user-visible damage from a stored non-number priority (a.priority - b.priorityis NaN).Repro#
Path:
repro/issue.test.mjsCommand:node --test repro/issue.test.mjsOutput (end):
TanStack Source bot, investigate agent