Skip to content

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

fix(signup): address review findings on product setup and invites

Scott Wilsone1d3ccecc002
diff --git a/backend/src/server/routes/v1/invite-org-router.ts b/backend/src/server/routes/v1/invite-org-router.ts
index b3d23935f9..9f62f11f48 100644
--- a/backend/src/server/routes/v1/invite-org-router.ts
+++ b/backend/src/server/routes/v1/invite-org-router.ts
@@ -137,7 +137,9 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
// The org invite above creates user records for every email, so leftovers mean
// some invitees silently missed the grant (the service skips them without throwing).
if (unresolved.length) {
- logger.error(`Failed to resolve invitees for PAM access [emails=${unresolved.join(",")}]`);
+ logger.error(
+ `Failed to resolve invitees for PAM access [unresolvedCount=${unresolved.length}] [orgId=${req.permission.orgId}]`
+ );
pamAccessFailed = true;
}
diff --git a/frontend/src/components/auth/ProductSelectionStep.tsx b/frontend/src/components/auth/ProductSelectionStep.tsx
index eff3003ecb..1749804e40 100644
--- a/frontend/src/components/auth/ProductSelectionStep.tsx
+++ b/frontend/src/components/auth/ProductSelectionStep.tsx
@@ -6,7 +6,7 @@ import { Button, CardContent, CardDescription, CardHeader, CardTitle } from "@ap
import { cn } from "@app/components/v3/utils";
import { EXAMPLE_PROJECT_NAME } from "@app/const";
import { isInfisicalCloud } from "@app/helpers/platform";
-import { initProjectHelper } from "@app/helpers/project";
+import { ensureExampleSecrets, initProjectHelper } from "@app/helpers/project";
import { submitSignupOnboarding } from "@app/hooks/api/auth/queries";
import { createWorkspace, fetchUserWorkspaces } from "@app/hooks/api/projects/queries";
import { Project, ProjectType } from "@app/hooks/api/projects/types";
@@ -35,7 +35,14 @@ const setUpProduct = async (product: SignupProductType): Promise<Project | undef
// with the project already created (cert-manager is even bootstrapped server-side), and the
// org is brand new, so any existing project of the type belongs to this flow.
const [existingProject] = await fetchUserWorkspaces(false, product);
- if (existingProject) return existingProject;
+ if (existingProject) {
+ // A prior attempt can have died between creating this project and seeding its
+ // example secrets; finish the seeding before treating the product as set up.
+ if (product === ProjectType.SecretManager) {
+ await ensureExampleSecrets(existingProject.id);
+ }
+ return existingProject;
+ }
switch (product) {
case ProjectType.SecretManager:
@@ -108,7 +115,15 @@ export default function ProductSelectionStep({
}
});
- onComplete(orderedSelection, { ...projects });
+ // The ref keeps every project created across attempts so retries stay idempotent, but a
+ // product deselected after a failed attempt must not reach the invite/completion steps.
+ const selectedProjects: Partial<Record<SignupProductType, Project>> = {};
+ orderedSelection.forEach((type) => {
+ const project = projects[type];
+ if (project) selectedProjects[type] = project;
+ });
+
+ onComplete(orderedSelection, selectedProjects);
} catch {
createNotification({
type: "error",
diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts
index 50b0050154..1a21fcb29d 100644
--- a/frontend/src/helpers/project.ts
+++ b/frontend/src/helpers/project.ts
@@ -11,6 +11,7 @@ import {
import { apiRequest } from "@app/config/request";
import { createWorkspace } from "@app/hooks/api/projects/queries";
import { Project, ProjectEnv, ProjectType } from "@app/hooks/api/projects/types";
+import { fetchProjectSecrets } from "@app/hooks/api/secrets/queries";
const secretsToBeAdded = [
{
@@ -38,6 +39,33 @@ const secretsToBeAdded = [
}
];
+const seedExampleSecrets = async (projectId: string) => {
+ await apiRequest.post("/api/v4/secrets/batch", {
+ projectId,
+ environment: "dev",
+ secretPath: "/",
+ secrets: secretsToBeAdded
+ });
+};
+
+/**
+ * Seed the example secrets into a project that may already have them: a prior attempt can
+ * have created the project but failed before seeding finished. Seeding is all-or-nothing
+ * server-side, so any existing secret means the project is already seeded.
+ */
+export const ensureExampleSecrets = async (projectId: string) => {
+ const { secrets } = await fetchProjectSecrets({
+ projectId,
+ environment: "dev",
+ secretPath: "/",
+ viewSecretValue: false
+ });
+
+ if (secrets.length === 0) {
+ await seedExampleSecrets(projectId);
+ }
+};
+
/**
* Create and initialize a new project in organization with id [organizationId]
* Note: current user should be a member of the organization
@@ -51,16 +79,9 @@ export const initProjectHelper = async ({ projectName }: { projectName: string }
type: ProjectType.SecretManager
});
- try {
- await apiRequest.post("/api/v4/secrets/batch", {
- projectId: project.id,
- environment: "dev",
- secretPath: "/",
- secrets: secretsToBeAdded
- });
- } catch (err) {
- console.error("Failed to upload secrets", err);
- }
+ // A seeding failure must propagate; swallowing it here would report the project as
+ // fully initialized and the example secrets would never be retried.
+ await seedExampleSecrets(project.id);
return project;
};