Skip to content

Conversation

@emlimlf
Copy link
Collaborator

@emlimlf emlimlf commented Dec 22, 2025

In this PR:

  • Display the proper error messages for duplicate project/subproject name in the UI

Ticket

CM-561


Note

Centralizes error handling and improves duplicate repository conflict messaging across integrations and project management flows.

  • Shared error handling:
    • Add shared/helpers/error-message.helper.ts with getAxiosErrorMessage, parseDuplicateRepoError, and customRepoErrorMessage to centralize Axios error parsing and duplicate repo conflict messaging.
  • Integrations UI:
    • Update git/gerrit/github settings drawers to use a unified errorHandler leveraging parseDuplicateRepoError and IntegrationService.find to show contextual conflict toasts; remove ad-hoc parsing.
    • Extend integration-store actions doGitConnect and doGerritConnect to accept and invoke optional errorHandler.
  • Admin & Segments:
    • Use getAxiosErrorMessage in lf-project-group-form.vue and segments actions.js to surface backend-provided messages for project group/project/sub-project create/update errors.

Written by Cursor Bugbot for commit 019eac6. This will update automatically on new commits. Configure here.

…rojects

Signed-off-by: Efren Lim <elim@linuxfoundation.org>
…rojects

Signed-off-by: Efren Lim <elim@linuxfoundation.org>
…/crowd.dev into chore/improve-error-messages
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Conventional Commits FTW!

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

3 similar comments
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@emlimlf emlimlf requested a review from joanagmaia December 22, 2025 07:13
@emlimlf emlimlf changed the title Chore/improve error messages chore: improve error messages Dec 22, 2025
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

'Trying to update repo (?<repo>[^\\s]+) mapping with integrationId (?<IId>[^\\s]+) '
+ 'but it is already mapped to integration (?<eId>[^\\s!]+)',
);
const match = errorMessage.match(pattern);
Copy link

Choose a reason for hiding this comment

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

Calling .match() on potentially non-string value crashes handler

The errorHandler function retrieves error?.response?.data into errorMessage and immediately calls .match() on it. If error.response.data is undefined (network error) or an object (JSON error response), calling .match() will throw a TypeError, causing the error handler itself to crash. The codebase follows a pattern of checking typeof error?.response?.data === 'string' before using string methods (as seen in groupsio-settings-drawer.vue and the new getAxiosErrorMessage helper), but this check is missing here.

Fix in Cursor Fix in Web

href: getSegmentLink(segment),
class: 'text-blue-500 underline hover:text-blue-600',
},
segment.name || 'Unknown Project',
Copy link

Choose a reason for hiding this comment

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

Accessing properties of potentially undefined segment object

The customErrorMessage function accesses segment.grandparentId, segment.id, and segment.name without checking if segment is defined. When IntegrationService.find(eId) returns an integration where integration.segment is null or undefined, passing it to customErrorMessage will cause a TypeError. The TODO comment on line 190 acknowledges potential data inconsistencies, making this edge case more likely to occur.

Additional Locations (1)

Fix in Cursor Fix in Web

Signed-off-by: Efren Lim <elim@linuxfoundation.org>
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

'Trying to update repo (?<repo>[^\\s]+) mapping with integrationId (?<IId>[^\\s]+) '
+ 'but it is already mapped to integration (?<eId>[^\\s!]+)',
);
const match = errorMessage.match(pattern);
Copy link

Choose a reason for hiding this comment

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

Calling match on undefined errorMessage causes crash

The parseDuplicateRepoError function calls errorMessage.match(pattern) without checking if errorMessage is defined. All callers pass error?.response?.data which can be undefined (e.g., network errors, timeouts, or errors without a response body). When errorMessage is undefined, calling .match() throws a TypeError, crashing the error handler instead of showing the default error message to users.

Additional Locations (2)

Fix in Cursor Fix in Web

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.

2 participants