Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(secret-approval): persist commit message on secret approval requests

Scott Wilsonb7416f50f68a
diff --git a/backend/src/db/migrations/20260629120000_add-commit-message-to-secret-approval-request.ts b/backend/src/db/migrations/20260629120000_add-commit-message-to-secret-approval-request.ts
new file mode 100644
index 0000000000..edeef707f0
--- /dev/null
+++ b/backend/src/db/migrations/20260629120000_add-commit-message-to-secret-approval-request.ts
@@ -0,0 +1,23 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// Stores the commit message a user enters when their secret changes are routed through an approval
+// policy, so reviewers can see the intent of the change request.
+export async function up(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.SecretApprovalRequest, "commitMessage");
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.SecretApprovalRequest, (table) => {
+ table.text("commitMessage").nullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.SecretApprovalRequest, "commitMessage");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.SecretApprovalRequest, (table) => {
+ table.dropColumn("commitMessage");
+ });
+ }
+}
diff --git a/backend/src/db/migrations/20260629120001_widen-secret-approval-request-bypass-reason.ts b/backend/src/db/migrations/20260629120001_widen-secret-approval-request-bypass-reason.ts
new file mode 100644
index 0000000000..42d0644f10
--- /dev/null
+++ b/backend/src/db/migrations/20260629120001_widen-secret-approval-request-bypass-reason.ts
@@ -0,0 +1,20 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// Widens SecretApprovalRequest.bypassReason from varchar(255) to text. Bypass reasons accept up to
+// 1000 characters at the API layer (secret-approval-request-router), so the original varchar(255)
+// rejects otherwise-valid input with a "value too long" error.
+export async function up(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.SecretApprovalRequest, "bypassReason");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.SecretApprovalRequest, (table) => {
+ table.text("bypassReason").nullable().alter();
+ });
+ }
+}
+
+// Intentionally a no-op: text is a superset of varchar(255), so widening needs no schema reversal.
+// Narrowing back to varchar(255) would throw "value too long" on any reason already stored beyond
+// 255 characters (exactly what this migration enables), wedging the rollback.
+export async function down(): Promise<void> {}
diff --git a/backend/src/db/schemas/secret-approval-requests.ts b/backend/src/db/schemas/secret-approval-requests.ts
index 10e9b6eaf6..80e0ebb976 100644
--- a/backend/src/db/schemas/secret-approval-requests.ts
+++ b/backend/src/db/schemas/secret-approval-requests.ts
@@ -20,7 +20,8 @@ export const SecretApprovalRequestsSchema = z.object({
isReplicated: z.boolean().nullable().optional(),
committerUserId: z.string().uuid().nullable().optional(),
statusChangedByUserId: z.string().uuid().nullable().optional(),
- bypassReason: z.string().nullable().optional()
+ bypassReason: z.string().nullable().optional(),
+ commitMessage: z.string().nullable().optional()
});
export type TSecretApprovalRequests = z.infer<typeof SecretApprovalRequestsSchema>;
diff --git a/backend/src/ee/services/pit/pit-service.ts b/backend/src/ee/services/pit/pit-service.ts
index 58fd24866c..a8ca6094e3 100644
--- a/backend/src/ee/services/pit/pit-service.ts
+++ b/backend/src/ee/services/pit/pit-service.ts
@@ -800,6 +800,7 @@ export const pitServiceFactory = ({
policy,
secretPath,
environment,
+ commitMessage: message,
projectId,
actor,
actorId,
diff --git a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
index 7da29efe0e..03456e8217 100644
--- a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
+++ b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
@@ -1752,6 +1752,7 @@ export const secretApprovalRequestServiceFactory = ({
projectId,
secretPath,
environment,
+ commitMessage,
trx: providedTx
}: TGenerateSecretApprovalRequestV2BridgeDTO & { trx?: Knex }) => {
if (actor === ActorType.SERVICE || actor === ActorType.IDENTITY)
@@ -2051,7 +2052,8 @@ export const secretApprovalRequestServiceFactory = ({
policyId: policy.id,
status: "open",
hasMerged: false,
- committerUserId: actorId
+ committerUserId: actorId,
+ commitMessage
},
tx
);
diff --git a/backend/src/ee/services/secret-approval-request/secret-approval-request-types.ts b/backend/src/ee/services/secret-approval-request/secret-approval-request-types.ts
index bb989e7fa5..4270be2a1d 100644
--- a/backend/src/ee/services/secret-approval-request/secret-approval-request-types.ts
+++ b/backend/src/ee/services/secret-approval-request/secret-approval-request-types.ts
@@ -60,6 +60,7 @@ export type TGenerateSecretApprovalRequestDTO = {
export type TGenerateSecretApprovalRequestV2BridgeDTO = {
environment: string;
secretPath: string;
+ commitMessage?: string;
policy: TSecretApprovalPolicies;
data: {
[SecretOperations.Create]?: TApprovalCreateSecretV2Bridge[];
diff --git a/frontend/src/hooks/api/secretApprovalRequest/types.ts b/frontend/src/hooks/api/secretApprovalRequest/types.ts
index 2c271ccf53..498d833dba 100644
--- a/frontend/src/hooks/api/secretApprovalRequest/types.ts
+++ b/frontend/src/hooks/api/secretApprovalRequest/types.ts
@@ -66,6 +66,9 @@ export type TSecretApprovalRequest = {
status: "open" | "close";
// Set when the request was merged without satisfying the policy's required approvals.
bypassReason?: string | null;
+ // Commit message captured when changes are submitted through a point-in-time commit.
+ // Not set for secret edits routed directly through an approval policy.
+ commitMessage?: string | null;
policy: Omit<TSecretApprovalPolicy, "approvers" | "bypassers"> & {
approvers: {
isOrgMembershipActive: boolean;
diff --git a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx
index c5ebfb3f73..e955064e88 100644
--- a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx
+++ b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx
@@ -558,6 +558,14 @@ export const SecretApprovalRequestChanges = ({
: formatReservedPaths(secretApprovalRequestDetails.secretPath)}
</DetailValue>
</Detail>
+ {secretApprovalRequestDetails.commitMessage && (
+ <Detail>
+ <DetailLabel>Message</DetailLabel>
+ <DetailValue className="break-words whitespace-pre-wrap">
+ {secretApprovalRequestDetails.commitMessage}
+ </DetailValue>
+ </Detail>
+ )}
</DetailGroup>
{reviewerRows.length > 0 && (