Skip to content

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

fix(api): include create secrets when resolving tags in bulk upsert

Muzzaiyyan Hussainb0d5b6a1b3fd
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
index f6d191904e..6b77ecdf80 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
@@ -2033,7 +2033,13 @@ export const secretV2BridgeServiceFactory = ({
});
// get all tags
- const sanitizedTagIds = [...new Set(secretsToUpdate.flatMap(({ tagIds = [] }) => tagIds))];
+ // get all tags (include create + update in upsert)
+ const inputSecrets = [...secretsToUpdate, ...secretsToCreate];
+
+ const sanitizedTagIds = [
+ ...new Set(inputSecrets.flatMap(({ tagIds = [] }) => tagIds))
+ ];
+
const tags = sanitizedTagIds.length ? await secretTagDAL.findManyTagsById(projectId, sanitizedTagIds, tx) : [];
if (tags.length !== sanitizedTagIds.length) throw new NotFoundError({ message: "Tag not found" });
const tagsGroupByID = groupBy(tags, (i) => i.id);