Skip to content

fix(frontend, v1.2): reject null payloads in dashboard type predicates - #7010

Open
Yicong-Huang wants to merge 1 commit into
apache:release/v1.2from
Yicong-Huang:backport/6443-reject-null-payloads-in-dashboard-type-p-v1.2
Open

fix(frontend, v1.2): reject null payloads in dashboard type predicates #7010
Yicong-Huang wants to merge 1 commit into
apache:release/v1.2from
Yicong-Huang:backport/6443-reject-null-payloads-in-dashboard-type-p-v1.2

Conversation

@Yicong-Huang

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Backport of #6443 to release/v1.2, cherry-picked from a4e03e4.

Source fix only. Test changes from #6443 were omitted (the touched specs do not exist on release/v1.2 or depend on main-only test infrastructure); only the source fix is carried over, per maintainer guidance.

Any related issues, documentation, discussions?

Backport of #6443. Originally linked #6439.

How was this PR tested?

Release-branch CI runs on this PR. Source change cherry-picked cleanly; test changes intentionally dropped.

Was this PR authored or co-authored using generative AI tooling?

Yes — backport prepared with Claude Code (mechanical cherry-pick + conflict resolution; the change itself is #6443 by its original author).

🤖 Generated with Claude Code

…che#6443)

### What changes were proposed in this PR?
The five type guards in `dashboard/type/type-predicates.ts` checked
their nested payload with `typeof value.<field> === "object"`, which
also accepts null because `typeof null === "object"` in JavaScript, so
an entry like `{workflow: null}` passed `isDashboardWorkflow` and the
`DashboardEntry` constructor then crashed with an unrelated `TypeError:
Cannot read properties of null` while dereferencing the payload, instead
of reaching its intentional `"Unexpected type in DashboardEntry."` error
path. The guards also returned the falsy input itself rather than
`false` for null/undefined input, violating their declared boolean
type-guard signatures.

This PR adds an `isNonNullObject` type guard (`typeof x === "object" &&
x !== null`) to the shared predicate utility
(`common/util/predicate.ts`, next to `isDefined`) so the correct
non-null object check is discoverable and reusable, uses it in the four
object-payload guards, and switches all five guards to `!!value && ...`
so they return strict booleans in every path. `isDashboardProject`'s
`!value.workflow` exclusion is deliberately unchanged: a null `workflow`
field means "no workflow data", so an object with a string `name` still
classifies as a project and no valid entry changes classification.

### Any related issues, documentation, discussions?
Fixes apache#6439. The buggy behavior was pinned by the five "(current
behavior)" tests added in apache#6425 (issue apache#6400), which this PR flips to
assert the corrected behavior.

### How was this PR tested?
Added `predicate.spec.ts` (8 tests) covering `isNonNullObject` and the
previously untested `isDefined`. Updated `type-predicates.spec.ts`: the
four null-payload pins now assert `toBe(false)`, the null/undefined
input cases are tightened from `toBeFalsy()` to `toBe(false)`, and the
`isDashboardProject` null-workflow case keeps asserting `true` with a
comment marking it as an intentional decision; the 5x5
cross-classification matrix and all of its 25 expected values are
untouched, confirming that classification of realistic entries is
unaffected. Ran locally via `yarn ng test --watch=false
--include='**/common/util/predicate.spec.ts'
--include='**/dashboard/type/type-predicates.spec.ts'` (61/61 pass),
plus the full frontend suite whose failure set is identical to the
unmodified main baseline (pre-existing, environment-related failures
only), and `tsc --noEmit` with zero errors.

### Was this PR authored or co-authored using generative AI tooling?
Co-authored using Claude Code(Fable 5).

---------

(backported from commit a4e03e4)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@Yicong-Huang
Yicong-Huang requested a review from xuang7 July 29, 2026 04:41
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan, @gracecluvohio
    You can notify them by mentioning @aglinxinyuan, @gracecluvohio in a comment.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 29, 2026
@Yicong-Huang Yicong-Huang removed the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.99%. Comparing base (fd5f487) to head (d374c98).
⚠️ Report is 2 commits behind head on release/v1.2.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
frontend/src/app/dashboard/type/type-predicates.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             release/v1.2    #7010      +/-   ##
==================================================
+ Coverage           53.95%   53.99%   +0.04%     
  Complexity           1441     1441              
==================================================
  Files                 809      809              
  Lines               34144    34146       +2     
  Branches             3448     3449       +1     
==================================================
+ Hits                18421    18438      +17     
+ Misses              14815    14801      -14     
+ Partials              908      907       -1     
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø) Carriedforward from fd5f487
agent-service 34.36% <ø> (ø) Carriedforward from fd5f487
amber 59.61% <ø> (ø) Carriedforward from fd5f487
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from fd5f487
config-service 56.06% <ø> (ø) Carriedforward from fd5f487
file-service 58.59% <ø> (ø) Carriedforward from fd5f487
frontend 47.26% <85.71%> (+0.07%) ⬆️
pyamber 90.87% <ø> (ø) Carriedforward from fd5f487
python 90.74% <ø> (ø) Carriedforward from fd5f487
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from fd5f487

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants