Skip to content

Fix staff candidate pages pendingField null access#101

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/staff-pendingfield-null-access
Open

Fix staff candidate pages pendingField null access#101
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/staff-pendingfield-null-access

Conversation

@sentry

@sentry sentry Bot commented Jun 14, 2026

Copy link
Copy Markdown

This PR addresses a TypeError: Cannot read properties of null (reading 'filter') that occurred when this.model.pendingField (or this.candidate.pendingField) was null in the API response. This happens when a candidate's profile is fully completed, and the backend's getPendingField() method returns null instead of an empty array.

The fix involves adding a fallback to an empty array (|| []) before calling .filter() on pendingField in the following files:

  • src/app/pages/logged-in/candidate/candidate-warning-list/candidate-warning-list.page.ts
  • src/app/pages/logged-in/candidate/candidate-salary-list/candidate-salary-list.page.ts
  • src/app/pages/logged-in/candidate/candidate-invitations/candidate-invitations.page.ts
  • src/app/pages/logged-in/candidate/candidate-notes/candidate-notes.page.ts
  • src/app/pages/logged-in/candidate/candidate-suggestions/candidate-suggestions.page.ts
  • src/app/pages/logged-in/candidate/candidate-view/candidate-view.page.ts

Note: src/app/pages/logged-in/candidate/candidate-form/candidate-form.page.ts already had a similar fix implemented in a previous commit.

Fixes SH-STAFF-APP-9
Fixes TECH-2033

@linear-code

linear-code Bot commented Jun 14, 2026

Copy link
Copy Markdown

TECH-2033

@netlify

netlify Bot commented Jun 14, 2026

Copy link
Copy Markdown

Deploy Preview for studenthub-staff ready!

Name Link
🔨 Latest commit 96936c8
🔍 Latest deploy log https://app.netlify.com/projects/studenthub-staff/deploys/6a2e8b76ae07a80008fcf285
😎 Deploy Preview https://deploy-preview-101--studenthub-staff.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines 647 to 651
if (this.candidate && this.candidate.pendingField && this.candidate.pendingField.length > 0) {
this.candidate.pendingField = this.candidate?.pendingField?.filter(v => v != "experience")
this.candidate.pendingField = (this.candidate?.pendingField || []).filter(v => v != "experience");
this.candidate.isProfileCompleted = this.candidate.pendingField.length == 0;

this.pendingData = 'Total ' + this.candidate.pendingField.length + ' pending fields\n ' + this.candidate.pendingField.join(',');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Bug: The check for pendingField does not handle the null case from the API, which can cause a runtime error in the template's *ngFor when iterating over the null value.
Severity: HIGH

Suggested Fix

Update the conditional check to if (this.candidate) to ensure the block always executes. This will correctly initialize this.candidate.pendingField to an empty array [] when it is null, preventing the template from receiving a null value and avoiding the runtime error.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
src/app/pages/logged-in/candidate/candidate-view/candidate-view.page.ts#L647-L651

Potential issue: The `if` condition at line 647 checks `this.candidate.pendingField &&
this.candidate.pendingField.length > 0`. When the API returns `null` for `pendingField`
(indicating a completed profile), this condition is false. The block is skipped, leaving
`this.candidate.pendingField` as `null`. When a user with a completed profile triggers
the 'pending-fields' popover, the template's `*ngFor` attempts to iterate over `null`,
causing a `TypeError` and a runtime crash. This also leads to incorrect UI states, such
as showing an 'Incomplete profile' badge for a completed profile.

Did we get this right? 👍 / 👎 to inform future reviews.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants