Skip to content

improvement: Add project name to secret approval notifications#5586

Merged
akhilmhdh merged 1 commit intoInfisical:mainfrom
frankeld:project-name-in-alerts
Mar 25, 2026
Merged

improvement: Add project name to secret approval notifications#5586
akhilmhdh merged 1 commit intoInfisical:mainfrom
frankeld:project-name-in-alerts

Conversation

@frankeld
Copy link
Copy Markdown
Contributor

@frankeld frankeld commented Mar 4, 2026

Context

Secret approval request notifications (Slack, Teams) didn't include the project name, making it hard to tell which project the request belongs to when you have multiple projects using one channel. Added projectName to the notification payload so it shows alongside environment, secret path, and secret keys.

Steps to verify the change

  1. Set up a Slack or Teams workflow integration for a project with an approval policy
  2. Trigger a secret approval request
  3. Confirm the notification now includes the project name

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Read the contributing guide

@maidul98
Copy link
Copy Markdown
Collaborator

maidul98 commented Mar 4, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR adds projectName to secret approval request notifications sent via Slack and Microsoft Teams, making it easier to identify which project triggered the notification when multiple projects share the same channel.

  • types.ts — Adds projectName: string to the TNotification payload type for SECRET_APPROVAL events.
  • slack-fns.ts — Prepends *Project*: <name> to the Slack message body above Environment.
  • microsoft-teams-fns.ts — Inserts a "Project" fact row before "Environment" in the Teams adaptive card.
  • secret-approval-request-service.ts — In generateSecretApprovalRequest, adds a new projectDAL.findById(projectId) call to populate the project name. In generateSecretApprovalRequestV2Bridge, reuses the project variable already in scope (no extra DB call needed there). The new lookup in generateSecretApprovalRequest has no null-safety guard — if the lookup ever returns null, accessing project.name would throw a TypeError and propagate up to the caller unexpectedly.

Confidence Score: 4/5

  • PR is safe to merge; the core logic is correct and the only concern is a minor missing null guard on a new DB lookup.
  • The changes are straightforward additions to an existing notification flow. The V2Bridge path was already cleanly handled. The single new findById call in generateSecretApprovalRequest works in practice (earlier guards ensure the project exists), but a defensive null check would make it more robust.
  • backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts — new findById call at line 1626 lacks a null check.

Important Files Changed

Filename Overview
backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts Adds a new projectDAL.findById call in generateSecretApprovalRequest to fetch the project name for notifications. The V2Bridge function already had the project in scope from a prior fetch. The new lookup lacks a null-safety guard, which is a minor risk if the project is not found.
backend/src/lib/workflow-integrations/types.ts Adds projectName: string to the SECRET_APPROVAL notification payload type. Change is clean and correct.
backend/src/services/slack/slack-fns.ts Prepends *Project*: ${payload.projectName} to the Slack message body for secret approval notifications. The ordering (Project → Environment → Path → Keys) is logical.
backend/src/services/microsoft-teams/microsoft-teams-fns.ts Adds a "Project" fact row before "Environment" in the Teams adaptive card FactSet. Change is clean and consistent with the Slack ordering.

Last reviewed commit: 7540d80

@akhilmhdh akhilmhdh merged commit 36e8c11 into Infisical:main Mar 25, 2026
4 checks passed
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