Skip to content

chore: add public API alerting#4089

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

chore: add public API alerting#4089
joanagmaia wants to merge 3 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: additive error-handling/alerting logic with no change to successful request paths, but it depends on a newly provisioned Slack webhook env var to avoid missing-alert warnings.

Overview
Public API conflict alerting: errorHandler now special-cases ConflictError (HTTP 409) to send a Slack warning with request details (method/URL plus optional params/body) and then returns the normal 409 JSON error response.

Slack integration update: Adds a new SlackChannel.CDP_LFX_SELF_SERVE_ALERTS and maps it to CDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URL so the new alerts can be routed to a dedicated channel.

Reviewed by Cursor Bugbot for commit 8b432c8. 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 on lines +30 to +35
`Public API Conflict 409: ${req.method} ${req.url}`,
[
{
title: 'Request',
text: `*Method:* \`${req.method}\`\n*URL:* \`${req.url}\``,
},
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 on lines +44 to +51
...(req.body && Object.keys(req.body).length > 0
? [
{
title: 'Body',
text: `\`\`\`${JSON.stringify(req.body, null, 2).substring(0, 1500)}\`\`\``,
},
]
: []),
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