mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3000] [Issue]: GET /agents/runs/:chatId/custom?limit=<non-numeric> returns an empty list instead of the default 50 #1574
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1574
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3000
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The custom-runs route parses
limitwithNumber.parseIntguarded only by truthiness of the raw string. For a non-numeric value like?limit=abc, the raw string is truthy soNumber.parseIntyields NaN, which is forwarded (not undefined), so the default of 50 does not apply. Inside the storage functionMath.max(1, Math.min(NaN, 200))is NaN androws.slice(0, NaN)returns[]. So a malformed limit query yields zero custom runs instead of the intended default.How to reproduce (try it yourself)
GET /api/agents/runs//custom?limit=abc
You'll see:
[]even when the chat has custom-agent runs.Expected: up to 50 custom runs (the default), exactly as GET .../custom with no limit returns.
Where it is
packages/server/src/routes/agents.routes.ts:155-156together withpackages/server/src/services/storage/agents.storage.ts:368-380.What's happening
NaN from
Number.parseIntis forwarded as the limit and is not normalized to the default;Math.min/Math.maxpropagate NaN, andArray.prototype.slice(0, NaN)coerces the end index to 0, yielding an empty array.Suggested fix
Guard the parse so non-finite values fall back to the default-parameter path, matching the codebase's established
Number.isFiniteidiom. In agents.routes.ts:155:With
parsedLimitundefined, the storage default of 50 applies. No regression: the only real-world caller (the client hook) passes no limit param, so the happy path is unchanged;?limit=0and valid numeric limits are unaffected. Optional defense-in-depth: also harden agents.storage.ts:369 toMath.max(1, Math.min(Number.isFinite(limit) ? limit : 50, 200)). Either guard alone fully resolves the bug; the route guard is the more surgical single-touch fix.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in merged staging PR #3004.