Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeError cannot read properties of undefined (reading 'name') #9562

Merged
merged 3 commits into from
May 29, 2024

Conversation

iamsivin
Copy link
Member

Pull Request Template

Description

Cause of this issue
I tried to replicate the issue by deleting the agent from super admin, but it didn't work. The error "TypeError: Cannot read properties of undefined (reading 'name')" suggests that agentInformation is undefined when accessing the name property. This likely occurs because the getAgentInformation method does not find an agent matching the given id, and thus returns undefined.

Solution
To resolve this issue, I modified the getAgentInformation method to handle cases where no agent is found. And added a fallback to the agent.name with agent.available_name. This change ensures that agentInformation will always be an object with its properties

Fixes https://linear.app/chatwoot/issue/CW-3325/typeerror-cannot-read-properties-of-undefined-reading-name

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

linear bot commented May 29, 2024

@iamsivin iamsivin requested a review from scmmishra May 29, 2024 15:45
@iamsivin iamsivin temporarily deployed to chatwoot-pr-9562 May 29, 2024 15:45 Inactive
@iamsivin iamsivin temporarily deployed to chatwoot-pr-9562 May 29, 2024 16:02 Inactive
@iamsivin iamsivin merged commit 41e27e9 into develop May 29, 2024
15 checks passed
@iamsivin iamsivin deleted the fix/CW-3325 branch May 29, 2024 16:34
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants