Skip to content

Conversation

@joanagmaia
Copy link
Contributor

@joanagmaia joanagmaia commented Dec 19, 2025

Changes

Repositories already mapped to other projects

Creating segments with names or slugs that already exist

  • If slug or name already exist in another project, throw a meaningful error.
    • Backend Message:
      • subprojectSlugExists: Sub-project with slug "{0}" already exists in project {1}.,
      • projectSlugExists: Project with slug "{0}" already exists in project group {1}.,
      • projectGroupSlugExists: Project Group with slug "{0}" already exists.,
      • subprojectNameExists: Sub-project {0} already exists in project {1}.,
      • projectNameExists: Project {0} already exists in project group {1}.,
      • projectGroupNameExists: Project Group {0} already exists.
    • Frontend should render exactly what it receives from backend (for segments (all levels) creation and update)

Note

Strengthens validation and user-facing errors for code integrations and segments.

  • Unifies backend error key to errors.integrations.repoAlreadyMapped; adds pre-checks to prevent mapping repos already linked to other integrations in gitConnectOrUpdate, GitLab repo mapping, and Gerrit connect (including URL normalization)
  • Adds segment duplicate detection: new findByName in repository and centralized checks in SegmentService to block conflicting name/slug across PROJECT_GROUP/PROJECT/SUB_PROJECT, with precise i18n messages and correct parent context; applied on create and update
  • Frontend refactor: introduces error-message.helper with parseDuplicateRepoError, getAxiosErrorMessage, and customRepoErrorMessage; integrates consistent error handling in Git, Gerrit, and both GitHub settings drawers; propagates errorHandler via store actions; improves admin project/segment toasts
  • i18n: adds specific segment duplicate messages and replaces GitHub-specific repo-mapped string with generic one

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

@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.

2 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.

@joanagmaia joanagmaia changed the title chore: improve api error messages chore: improve api error messages (CM-855) Dec 19, 2025
if (data.name || data.slug) {
await this.validateUpdateDuplicates(id, segment, data, segmentRepository)
}

Copy link

Choose a reason for hiding this comment

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

Bug: Update validation misses slug conflicts from isLF transformation

When updating a segment, validateUpdateDuplicates skips slug validation if data.slug === segment.slug (line 735). However, the slug is subsequently transformed by validateNonLfSlug when isLF changes to false (line 54). The transformed slug (with nonlf_ prefix) is never validated for conflicts. This allows creating duplicate slugs when a user updates a segment with the same slug value but changes isLF from true to false, potentially colliding with an existing segment that already has the nonlf_-prefixed version of that slug.

Additional Locations (1)

Fix in Cursor Fix in Web

Signed-off-by: Efren Lim <elim@linuxfoundation.org>
'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.

parseDuplicateRepoError crashes on non-string input

The parseDuplicateRepoError function calls errorMessage.match(pattern) without checking if errorMessage is a string. The callers pass error?.response?.data which can be undefined (on network errors or timeouts), null, or an object (if the API returns JSON). When errorMessage is not a string, calling .match() throws a TypeError, which will crash the error handler and prevent proper error display. The function needs to validate that errorMessage is a string before calling .match().

Additional Locations (2)

Fix in Cursor Fix in Web

const remotes = integrationData.remote.repoNames.map((repoName) => {
const fullUrl = stripGit(`${integrationData.remote.orgURL}/${repoName}`)
return { url: fullUrl, forkedFrom: null }
})
Copy link

Choose a reason for hiding this comment

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

Gerrit remotes built before enableAllRepos updates repoNames

The remotes array is built from integrationData.remote.repoNames before getGerritServerRepos is called. When enableAllRepos is true, integrationData.remote.repoNames gets updated with the full server list at line 1767, but remotes still contains the initial (possibly empty or partial) list. This causes two problems: the conflict check (lines 1729-1763) only validates the initial repos, and gitConnectOrUpdate (line 1806) only syncs the initial repos, while the integration settings store the complete list. This mismatch means repositories could be added without proper conflict checking and won't be synced to git.

Additional Locations (1)

Fix in Cursor Fix in Web

`SELECT id, settings FROM integrations
WHERE platform = 'gerrit' AND "deletedAt" IS NULL AND id != :currentIntegrationId`,
{
replacements: { currentIntegrationId: integration?.id || connectionId },
Copy link

Choose a reason for hiding this comment

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

Gerrit conflict check uses undefined currentIntegrationId

The Gerrit conflict check at line 1735 uses integration?.id || connectionId as currentIntegrationId, but both variables are undefined at this point in execution (they're assigned at lines 1770 and 1782, respectively). This causes two problems: the SQL query id != :currentIntegrationId with undefined doesn't exclude any rows (SQL id != NULL evaluates to NULL, not true), so for updates the check could incorrectly flag the integration's own repos as conflicts. Additionally, the error message at line 1757 would display undefined as the integration ID.

Additional Locations (1)

Fix in Cursor Fix in Web

@joanagmaia joanagmaia merged commit 050ad7d into main Jan 5, 2026
16 checks passed
@joanagmaia joanagmaia deleted the chore/improve-api-error-messages branch January 5, 2026 12:21
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.

4 participants