Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions frontend/src/app/dashboard/type/type-predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,23 @@ import { DashboardProject } from "./dashboard-project.interface";
import { DashboardFile } from "./dashboard-file.interface";
import { DashboardDataset } from "./dashboard-dataset.interface";
import { DashboardWorkflowComputingUnit } from "../../common/type/workflow-computing-unit";
import { isNonNullObject } from "../../common/util/predicate";

export function isDashboardWorkflow(value: any): value is DashboardWorkflow {
return !!value && isNonNullObject(value.workflow);
return value && typeof value.workflow === "object";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Restore the removed non-null object guard.

typeof null === "object", so Lines 27, 35, 39, and 43 accept values such as { workflow: null }, { file: null }, { dataset: null }, and { computingUnit: null }. Line 31 also accepts a function with a string name and no workflow. These are false-positive type guards. Restore isNonNullObject(value) and apply it to each nested object field.

Also applies to: 31-31, 35-35, 39-39, 43-43

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/app/dashboard/type/type-predicates.ts` at line 27, Update the
type predicates in type-predicates.ts to use isNonNullObject(value) for the
input and for each nested workflow, file, dataset, and computingUnit field,
preventing null values from passing as objects. In the predicate covering name
and workflow, require the workflow property to be a non-null object rather than
accepting a function with only a string name.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Return a boolean from every predicate.

Each value && ... expression returns null, undefined, 0, or "" for some falsy inputs. The is... functions should return false for invalid values. Wrap each expression with Boolean(...) after restoring the null-safe checks.

Proposed fix
-  return value && typeof value.workflow === "object";
+  return Boolean(value && value.workflow !== null && typeof value.workflow === "object");

Apply the same boolean coercion to the other predicates.

Also applies to: 31-31, 35-35, 39-39, 43-43

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/app/dashboard/type/type-predicates.ts` at line 27, Update all
predicates in type-predicates.ts, including the one checking value.workflow and
the predicates at the referenced locations, to return explicit booleans.
Preserve their null-safe checks, but wrap each value && ... expression with
Boolean(...) so every invalid or falsy input returns false rather than the
original falsy value.

}

export function isDashboardProject(value: any): value is DashboardProject {
return !!value && typeof value.name === "string" && !value.workflow;
return value && typeof value.name === "string" && !value.workflow;
}

export function isDashboardFile(value: any): value is DashboardFile {
return !!value && typeof value.ownerEmail === "string" && isNonNullObject(value.file);
return value && typeof value.ownerEmail === "string" && typeof value.file === "object";
}

export function isDashboardDataset(value: any): value is DashboardDataset {
return !!value && isNonNullObject(value.dataset);
return value && typeof value.dataset === "object";
}

export function isDashboardWorkflowComputingUnit(value: any): value is DashboardWorkflowComputingUnit {
return !!value && isNonNullObject(value.computingUnit);
return value && typeof value.computingUnit === "object";
}