fix/duration-filters - #2127
Open
alanpeixinho wants to merge 4 commits into
Open
fix/duration-filters#2127alanpeixinho wants to merge 4 commits into
alanpeixinho wants to merge 4 commits into
Conversation
Member
There was a problem hiding this comment.
I think these tests does not cover the POST path used by Tree Details and Hardware Details, right?
worth adding a process_body=True
Comment on lines
+213
to
+217
| if (value === '') { | ||
| delete next[field]; | ||
| } else { | ||
| next[field] = Number.parseInt(value, 10); | ||
| } |
Member
There was a problem hiding this comment.
this guards '' but other values can also become NaN.
Even if the input is of type number, I think it's worth using Number.isFinite to validate the parsed value.
Closes kernelci#428 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Closes kernelci#2126 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
alanpeixinho
force-pushed
the
fix/duration-filters-428-2126
branch
from
September 23, 2026 12:58
d5b4e70 to
f232d48
Compare
Comment on lines
+163
to
+169
| export const getActiveDurationFilter = (value: unknown): number | undefined => { | ||
| if (value === undefined || value === null || value === '') { | ||
| return undefined; | ||
| } | ||
| const n = typeof value === 'number' ? value : Number(value); | ||
| return Number.isFinite(n) && n !== 0 ? n : undefined; | ||
| }; |
Member
There was a problem hiding this comment.
I'm pondering if this is too permissive. Since value is unknown we can get anything here.
Maybe we should do something like:
export const getActiveDurationFilter = (
value: unknown,
): number | undefined => {
if (typeof value !== 'string' && typeof value !== 'number') {
return undefined;
}
if (typeof value === 'string' && value.trim() === '') {
return undefined;
}
const n = Number(value);
return Number.isFinite(n) && n !== 0 ? n : undefined;
};OR restricting the type of value param
Contributor
Author
There was a problem hiding this comment.
Included extra guard.
Only treat string/number as duration, drop NaN from input state, and cover hardware POST body so 3600 is not truncated. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
felipebergamin
approved these changes
Sep 24, 2026
Empty and whitespace-only values should not ride on Number('') === 0.
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
alanpeixinho
force-pushed
the
fix/duration-filters-428-2126
branch
from
September 25, 2026 18:46
519db36 to
8ef89cf
Compare
felipebergamin
approved these changes
Sep 25, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it is
Fixes duration filter handling in the dashboard and API:
longer truncates multi-digit values (e.g. 3600 → 3) when filters come from the query string.
Closes #428
Closes #2126
How to test