chore: add public API alerting#4089
Conversation
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
2 similar comments
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
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_ALERTSto route LFX self-serve conflict alerts separately. - Mapped the new channel to
CDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URL. - Updated the Public API
errorHandlerto detectConflictErrorand 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.
| const log = getServiceLogger() | ||
|
|
||
| const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = { | ||
| const CHANNEL_WEBHOOK_URLS: Record = { |
There was a problem hiding this comment.
This looks like a legit regression - the types are gone now for the constant.
| `Public API Conflict 409: ${req.method} ${req.url}`, | ||
| [ | ||
| { | ||
| title: 'Request', | ||
| text: `*Method:* \`${req.method}\`\n*URL:* \`${req.url}\``, | ||
| }, |
| const log = getServiceLogger() | ||
|
|
||
| const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = { | ||
| const CHANNEL_WEBHOOK_URLS: Record = { |
There was a problem hiding this comment.
This looks like a legit regression - the types are gone now for the constant.
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
| ...(req.body && Object.keys(req.body).length > 0 | ||
| ? [ | ||
| { | ||
| title: 'Body', | ||
| text: `\`\`\`${JSON.stringify(req.body, null, 2).substring(0, 1500)}\`\`\``, | ||
| }, | ||
| ] | ||
| : []), |
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.
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:
ConflictErrorin the public API'serrorHandlermiddleware, which now sends a Slack notification to the newCDP_LFX_SELF_SERVE_ALERTSchannel when a conflict occurs, providing request and error details.ConflictErrorfrom@crowd/common.Slack Integration Updates:
CDP_LFX_SELF_SERVE_ALERTSinSlackChannelto support targeted alerting.CDP_LFX_SELF_SERVE_ALERTSchannel, 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:
errorHandlernow special-casesConflictError(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_ALERTSand maps it toCDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URLso 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.