Skip to content

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

refactor(migration): rename vaultConfig to existingConfig and widen findOne filter type

Igor Correa12d6bb0930a1
diff --git a/backend/src/services/external-migration/external-migration-service.ts b/backend/src/services/external-migration/external-migration-service.ts
index a198372d57..7680972c74 100644
--- a/backend/src/services/external-migration/external-migration-service.ts
+++ b/backend/src/services/external-migration/external-migration-service.ts
@@ -161,29 +161,29 @@ export const externalMigrationServiceFactory = ({
throw new ForbiddenRequestError({ message: `Only admins can ${action}` });
}
- const vaultConfig = await vaultExternalMigrationConfigDAL.findOne({
+ const existingConfig = await vaultExternalMigrationConfigDAL.findOne({
orgId: actor.orgId,
namespace,
provider: ExternalMigrationProviders.Vault
});
- if (!vaultConfig) {
+ if (!existingConfig) {
throw new NotFoundError({ message: "Vault migration config not found for this namespace" });
}
- if (!vaultConfig.connection) {
+ if (!existingConfig.connection) {
throw new BadRequestError({ message: "Vault migration connection is not configured for this namespace" });
}
const credentials = await decryptAppConnectionCredentials({
- orgId: vaultConfig.orgId,
- encryptedCredentials: vaultConfig.connection.encryptedCredentials,
+ orgId: existingConfig.orgId,
+ encryptedCredentials: existingConfig.connection.encryptedCredentials,
kmsService,
projectId: null
});
return {
- ...vaultConfig.connection,
+ ...existingConfig.connection,
credentials
} as THCVaultConnection;
};
@@ -804,11 +804,7 @@ export const externalMigrationServiceFactory = ({
});
};
- const updateDopplerExternalMigration = async ({
- id,
- connectionId,
- actor
- }: TUpdateDopplerExternalMigrationDTO) => {
+ const updateDopplerExternalMigration = async ({ id, connectionId, actor }: TUpdateDopplerExternalMigrationDTO) => {
const { hasRole } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.Any,
actor: actor.type,
diff --git a/backend/src/services/external-migration/vault-external-migration-config-dal.ts b/backend/src/services/external-migration/vault-external-migration-config-dal.ts
index 6acf11b662..e9c3b9b54e 100644
--- a/backend/src/services/external-migration/vault-external-migration-config-dal.ts
+++ b/backend/src/services/external-migration/vault-external-migration-config-dal.ts
@@ -9,7 +9,11 @@ export type TVaultExternalMigrationConfigDALFactory = ReturnType<typeof vaultExt
const buildConnectionJoin = (qb: Knex.QueryBuilder, db: TDbClient) =>
qb
- .leftJoin(TableName.AppConnection, `${TableName.AppConnection}.id`, `${TableName.ExternalMigrationConfig}.connectionId`)
+ .leftJoin(
+ TableName.AppConnection,
+ `${TableName.AppConnection}.id`,
+ `${TableName.ExternalMigrationConfig}.connectionId`
+ )
.select(selectAllTableCols(TableName.ExternalMigrationConfig))
.select(
db.ref("id").withSchema(TableName.AppConnection).as("appConnectionId"),
@@ -54,7 +58,10 @@ const mapResultToConnection = (raw: Record<string, unknown>) => {
export const vaultExternalMigrationConfigDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.ExternalMigrationConfig);
- const findOne = async (filter: { orgId: string; namespace?: string; provider?: string }, tx?: Knex) => {
+ const findOne = async (
+ filter: { orgId: string; namespace?: string; provider?: string; connectionId?: string | null },
+ tx?: Knex
+ ) => {
try {
const qb = (tx || db?.replicaNode?.() || db)(TableName.ExternalMigrationConfig);
buildConnectionJoin(qb, db);