Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ export function VercelOnboardingModal({
formData.append("atomicBuilds", JSON.stringify(atomicBuilds));
formData.append("discoverEnvVars", JSON.stringify(discoverEnvVars));
formData.append("syncEnvVarsMapping", JSON.stringify(syncEnvVarsMapping));
if (fromMarketplaceContext) {
formData.append("origin", "marketplace");
}
if (nextUrl && fromMarketplaceContext && isGitHubConnectedForOnboarding) {
formData.append("next", nextUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { parse } from "@conform-to/zod";
import { CheckCircleIcon, LockClosedIcon, PlusIcon } from "@heroicons/react/20/solid";
import { Form, useActionData, useNavigation, useNavigate, useSearchParams, useLocation } from "@remix-run/react";
import { type ActionFunctionArgs, type LoaderFunctionArgs, json } from "@remix-run/server-runtime";
import { typedjson, useTypedFetcher } from "remix-typedjson";
import { redirect,
typedjson, useTypedFetcher } from "remix-typedjson";
import { z } from "zod";
import { OctoKitty } from "~/components/GitHubLoginButton";
import { Dialog, DialogContent, DialogHeader, DialogTrigger } from "~/components/primitives/Dialog";
Expand Down Expand Up @@ -39,6 +40,7 @@ import { findProjectBySlug } from "~/models/project.server";
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
import { ProjectSettingsService } from "~/services/projectSettings.server";
import { logger } from "~/services/logger.server";
import { triggerInitialDeployment } from "~/services/platform.v3.server";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify triggerInitialDeployment implementation and idempotency

# Find the implementation of triggerInitialDeployment
ast-grep --pattern 'export $_ function triggerInitialDeployment($$$) {
  $$$
}'

# Alternative: search for the function definition
rg -nA20 "export.*triggerInitialDeployment" apps/webapp/app/services/platform.v3.server.ts

# Check if there are guards against duplicate deployments
rg -n "triggerInitialDeployment" apps/webapp/app/services/

Repository: triggerdotdev/trigger.dev

Length of output: 51


🏁 Script executed:

# First, let's verify the file under review exists
fd "github.tsx" apps/webapp/app/routes/ --type f

Repository: triggerdotdev/trigger.dev

Length of output: 172


🏁 Script executed:

# Let's search for triggerInitialDeployment across the entire codebase without path assumptions
rg "triggerInitialDeployment" --type ts --type tsx -l

Repository: triggerdotdev/trigger.dev

Length of output: 96


🏁 Script executed:

# Check if platform.v3.server file exists and what it contains
find apps/webapp -name "*platform*" -type f | head -20

Repository: triggerdotdev/trigger.dev

Length of output: 115


🏁 Script executed:

# Search for triggerInitialDeployment with correct file type (ts includes tsx)
rg "triggerInitialDeployment" --type ts -B 2 -A 10

Repository: triggerdotdev/trigger.dev

Length of output: 3842


🏁 Script executed:

# Read the github.tsx file to see the context and how it's used
cat -n apps/webapp/app/routes/resources.orgs.\$organizationSlug.projects.\$projectParam.env.\$envParam.github.tsx | head -100

Repository: triggerdotdev/trigger.dev

Length of output: 4799


🏁 Script executed:

# Read the platform.v3.server.ts file to find the function definition
cat -n apps/webapp/app/services/platform.v3.server.ts

Repository: triggerdotdev/trigger.dev

Length of output: 23536


🏁 Script executed:

# Search for triggerInitialDeployment definition across entire codebase
rg "export.*triggerInitialDeployment" --type ts -B 2 -A 5

Repository: triggerdotdev/trigger.dev

Length of output: 51


🏁 Script executed:

# Search for any mention of triggerInitialDeployment to understand if it's defined anywhere
rg "triggerInitialDeployment" --type ts -B 1 -A 1

Repository: triggerdotdev/trigger.dev

Length of output: 1031


🏁 Script executed:

# Check what other files exist in services directory
ls -la apps/webapp/app/services/ | head -30

Repository: triggerdotdev/trigger.dev

Length of output: 2200


🏁 Script executed:

# Get full listing of services directory
find apps/webapp/app/services/ -name "*.ts" -type f | sort

Repository: triggerdotdev/trigger.dev

Length of output: 4474


🏁 Script executed:

# Check if triggerInitialDeployment might be in other platform-related files
rg "triggerInitialDeployment" --type ts --type tsx --type js --type jsx

Repository: triggerdotdev/trigger.dev

Length of output: 96


🏁 Script executed:

# Search for "initialDeployment" or similar functions in platform files
rg "initialDeployment|Initial.*[Dd]eployment" --type ts -B 2 -A 8

Repository: triggerdotdev/trigger.dev

Length of output: 31210


Remove non-existent import: triggerInitialDeployment is not exported from platform.v3.server.ts.

The function triggerInitialDeployment imported on line 43 does not exist in ~/services/platform.v3.server.ts. This will cause a runtime error. Replace with the correct initialization service: InitializeDeploymentService from ~/v3/services/initializeDeployment.server.ts or verify the correct function name and location.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/webapp/app/routes/resources.orgs`.$organizationSlug.projects.$projectParam.env.$envParam.github.tsx
at line 43, The import of triggerInitialDeployment is invalid; remove the
non-existent import and replace it with the correct initializer symbol
(InitializeDeploymentService) from the initialize-deployment service module,
update any calls that used triggerInitialDeployment to use
InitializeDeploymentService (or its exported method) and adjust
invocation/signature to match the new API so the component references the
correct exported symbol.

import { requireUserId } from "~/services/session.server";
import {
githubAppInstallPath,
Expand Down Expand Up @@ -208,6 +210,18 @@ export async function action({ request, params }: ActionFunctionArgs) {
);

if (resultOrFail.isOk()) {
// Trigger initial deployment for marketplace flows now that GitHub is connected
if (redirectUrl) {
try {
if (redirectUrl.includes("origin=marketplace")) {
await triggerInitialDeployment(projectId, { environment: "prod" });
}
} catch (error) {
logger.error("Invalid redirect URL, skipping initial deployment trigger", { redirectUrl, error });
// Invalid redirectUrl, skip initial deployment check
}
}
Comment on lines +213 to +223
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fragile origin detection and conflated error handling.

Two concerns with this implementation:

  1. String matching is fragile: Using redirectUrl.includes("origin=marketplace") can produce false positives (e.g., notorigin=marketplace or origin=marketplace-v2). Consider parsing the URL and checking search params properly.

  2. Error handling conflates different failures: The try-catch wraps both the URL check and triggerInitialDeployment, but the error message says "Invalid redirect URL". If triggerInitialDeployment fails, the logged message will be misleading.

🔧 Proposed fix for robust origin detection
       // Trigger initial deployment for marketplace flows now that GitHub is connected
       if (redirectUrl) {
         try {
-          if (redirectUrl.includes("origin=marketplace")) {
+          const redirectUrlParams = new URL(redirectUrl, "http://placeholder").searchParams;
+          if (redirectUrlParams.get("origin") === "marketplace") {
             await triggerInitialDeployment(projectId, { environment: "prod" });
           }
         } catch (error) {
-          logger.error("Invalid redirect URL, skipping initial deployment trigger", { redirectUrl, error });
-          // Invalid redirectUrl, skip initial deployment check
+          logger.warn("Failed to trigger initial deployment for marketplace flow", { redirectUrl, error });
         }
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/webapp/app/routes/resources.orgs`.$organizationSlug.projects.$projectParam.env.$envParam.github.tsx
around lines 213 - 223, Replace the fragile includes-based check with proper URL
parsing and split error handling: use the URL constructor on redirectUrl and
check url.searchParams.get("origin") === "marketplace" (referencing redirectUrl)
before calling triggerInitialDeployment(projectId, { environment: "prod" });
move the triggerInitialDeployment call into its own try-catch so parsing errors
are logged as "Invalid redirect URL" via logger.error(…) and deployment failures
are logged separately (e.g., "Initial deployment trigger failed") with the error
object; reference triggerInitialDeployment and logger.error in the new
structure.


return redirectWithMessage(
request,
redirectUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const CompleteOnboardingFormSchema = z.object({
syncEnvVarsMapping: z.string().optional(),
next: z.string().optional(),
skipRedirect: z.string().optional().transform((val) => val === "true"),
origin: z.string().optional(),
});

const SkipOnboardingFormSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/services/vercelIntegration.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export class VercelIntegrationService {
});

if (upsertResult.isErr()) {
logger.error("Failed to sync staging TRIGGER_SECRET_KEY to custom environment", {
logger.warn("Failed to sync staging TRIGGER_SECRET_KEY to custom environment", {
projectId,
newCustomEnvironmentId,
error: upsertResult.error.message,
Expand Down
Loading