Skip to content

chore: add public API alerting#4089

Open
joanagmaia wants to merge 7 commits intomainfrom
chore/public-api-alerting
Open

chore: add public API alerting#4089
joanagmaia wants to merge 7 commits intomainfrom
chore/public-api-alerting

Conversation

@joanagmaia
Copy link
Copy Markdown
Contributor

@joanagmaia joanagmaia commented May 7, 2026

Issue reported by the LF SS team: https://linuxfoundation.atlassian.net/browse/LFXV2-1578?focusedCommentId=111986&sourceType=mention. The 409 error is thrown when the LF SS api tries to query our API for 2 identities that belong to different users. For now we want to fix these profiles manually. This will be given to the data quality team.

⚠️ Do not merge this PR until the new slack channel and webhook are provisioned.

This pull request enhances error handling and alerting for the public API by introducing a new Slack alert channel specifically for conflict errors (HTTP 409). It also updates the Slack integration to support this new channel. The most important changes are grouped below:

Error Handling Improvements:

  • Added handling for ConflictError in the public API's errorHandler middleware, which now sends a Slack notification to the new CDP_LFX_SELF_SERVE_ALERTS channel when a conflict occurs, providing request and error details.
  • Updated the middleware imports to include the new ConflictError from @crowd/common.

Slack Integration Updates:

  • Added a new Slack channel enum value CDP_LFX_SELF_SERVE_ALERTS in SlackChannel to support targeted alerting.
  • Updated the Slack channel webhook URL mapping to include the new CDP_LFX_SELF_SERVE_ALERTS channel, using its corresponding environment variable for the webhook URL.

Note

Low Risk
Low risk: adds Slack alerting and logging for ConflictError (HTTP 409) in the public API plus a new Slack channel/env var mapping, without changing success-path behavior or data handling.

Overview
Adds targeted Slack alerting for public API 409 conflicts: errorHandler now special-cases ConflictError, logs a warning, and posts a structured message (including optional memberIds) to the new CDP_LFX_SELF_SERVE_ALERTS channel before returning the normal 409 JSON.

Updates resolveMemberByIdentities to attach the conflicting memberIds to the thrown ConflictError for alert context, and extends the Slack library with the CDP_LFX_SELF_SERVE_ALERTS enum value and webhook env var mapping.

Reviewed by Cursor Bugbot for commit 142d894. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
@joanagmaia joanagmaia requested a review from themarolt May 7, 2026 14:53
@joanagmaia joanagmaia self-assigned this May 7, 2026
Copilot AI review requested due to automatic review settings May 7, 2026 14:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ 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
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ 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
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted Slack alerting for Public API 409 Conflict errors (to support manual remediation of conflicting identities), and extends the shared Slack library with a dedicated channel + webhook mapping.

Changes:

  • Added SlackChannel.CDP_LFX_SELF_SERVE_ALERTS to route LFX self-serve conflict alerts separately.
  • Mapped the new channel to CDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URL.
  • Updated the Public API errorHandler to detect ConflictError and send a Slack notification on 409s.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
services/libs/slack/src/types.ts Adds a new SlackChannel enum value for LFX self-serve conflict alerting.
services/libs/slack/src/channels.ts Adds env var mapping for the new channel (but currently introduces a TypeScript typing error).
backend/src/api/public/middlewares/errorHandler.ts Sends a Slack notification when a ConflictError occurs in the public API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/slack/src/channels.ts Outdated
const log = getServiceLogger()

const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = {
const CHANNEL_WEBHOOK_URLS: Record = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a legit regression - the types are gone now for the constant.

Comment thread backend/src/api/public/middlewares/errorHandler.ts
Comment thread services/libs/slack/src/channels.ts Outdated
const log = getServiceLogger()

const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = {
const CHANNEL_WEBHOOK_URLS: Record = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a legit regression - the types are gone now for the constant.

joanagmaia added 2 commits May 8, 2026 10:04
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 8, 2026 09:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

⚠️ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread backend/src/api/public/middlewares/errorHandler.ts Outdated
joanagmaia added 2 commits May 8, 2026 10:23
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 8, 2026 10:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread backend/src/api/public/v1/members/resolveMember.ts Outdated
Comment thread backend/src/api/public/middlewares/errorHandler.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2edd497. Configure here.

Comment thread backend/src/api/public/middlewares/errorHandler.ts
joanagmaia added 2 commits May 8, 2026 11:44
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 8, 2026 14:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread backend/src/api/public/middlewares/errorHandler.ts
Comment on lines +35 to +41
const error = new ConflictError('Conflicting identities')
Object.defineProperty(error, 'memberIds', {
value: memberIds,
enumerable: false,
configurable: true,
})
throw error
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.

3 participants