eugenegujing opened a new issue, #6439:
URL: https://github.com/apache/texera/issues/6439
### What happened?
The type guards in `frontend/src/app/dashboard/type/type-predicates.ts`
check their nested payload with `typeof value.<field> === "object"`. Since
`typeof null === "object"` in JavaScript, an entry with a null payload wrongly
passes, e.g. `isDashboardWorkflow({ workflow: null })` returns `true` (same for
the `file`, `dataset`, and `computingUnit` guards). The guards also return the
falsy input itself instead of `false` for null/undefined input, because they
are written as `return value && <check>`.
The `DashboardEntry` constructor trusts the guards and dereferences the
payload directly (`value.workflow.wid`), so such an entry throws `TypeError:
Cannot read properties of null`, breaking rendering of the whole
dashboard/search list. Current backend endpoints never send null here, so this
is latent, but any future serialization change or new `DashboardEntry` caller
can trigger it.
Expected: a null payload should fail every guard so the entry falls through
to the constructor's existing `"Unexpected type in DashboardEntry."` error, and
guards should always return booleans.
### How to reproduce?
Unit-level (no app needed): in any frontend spec or a TS scratch file, run
```ts
import { isDashboardWorkflow } from "src/app/dashboard/type/type-predicates";
import { DashboardEntry } from "src/app/dashboard/type/dashboard-entry";
console.log(isDashboardWorkflow({ workflow: null })); // true — expected
false
new DashboardEntry({ workflow: null } as any); // TypeError: Cannot read
properties of null (reading 'wid')
```
Equivalently, the merged spec demonstrates it: run `yarn ng test
--watch=false --include='**/dashboard/type/type-predicates.spec.ts'` from
`frontend/` and see the five passing tests titled "(current behavior)", each
asserting that a null payload passes its guard.
### Version/Branch
1.3.0-incubating-SNAPSHOT (main)
### Commit Hash (Optional)
_No response_
### What browsers are you seeing the problem on?
_No response_
### Relevant log output
```shell
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]