Skip to content
Merged
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion apps/api/src/handlers/environments/createEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import {
type TaskPayload,
environmentConfigSchema,
getAmbiguousEnvironmentRepositoryError,
getDuplicateEnvironmentRepositoryConfigError,
getMissingEnvironmentRepositoryError,
getEnvironmentRepositoryInstallationError,
} from '@roomote/types';
Expand Down Expand Up @@ -69,7 +71,10 @@ export function getEnvironmentRepositoryConfigError(
installationId: string | number | null | undefined;
}>,
): string | null {
return getEnvironmentRepositoryInstallationError(repositoryRows);
return (
getAmbiguousEnvironmentRepositoryError(repositoryRows) ??
getEnvironmentRepositoryInstallationError(repositoryRows)
);
}

function extractRunId(auth: McpAuth): number | null {
Expand Down Expand Up @@ -252,6 +257,19 @@ export async function createEnvironment(
}

const config = parsedConfig.data;
const duplicateRepositoryError = getDuplicateEnvironmentRepositoryConfigError(
config.repositories,
);

if (duplicateRepositoryError) {
return c.json(
{
error: `Invalid environment configuration: ${duplicateRepositoryError}`,
},
400,
);
}

try {
const existing = await db.query.environments.findFirst({
where: eq(environments.name, config.name),
Expand Down
12 changes: 12 additions & 0 deletions apps/api/src/handlers/environments/updateEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@roomote/db/server';
import {
environmentConfigSchema,
getDuplicateEnvironmentRepositoryConfigError,
getMissingEnvironmentRepositoryError,
} from '@roomote/types';

Expand Down Expand Up @@ -90,6 +91,17 @@ export async function updateEnvironment(
}

const config = parsedConfig.data;
const duplicateRepositoryError =
getDuplicateEnvironmentRepositoryConfigError(config.repositories);

if (duplicateRepositoryError) {
return c.json(
{
error: `Invalid environment configuration: ${duplicateRepositoryError}`,
},
400,
);
}

const environment = await db.query.environments.findFirst({
where: eq(environments.id, id),
Expand Down
87 changes: 77 additions & 10 deletions apps/api/src/handlers/tasks/__tests__/launchTask.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading