The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
[codex] Reject stale company skill refreshes (#4601)
Dotta6ccf80bcf2d2
diff --git a/server/src/__tests__/company-skills-service.test.ts b/server/src/__tests__/company-skills-service.test.tsindex b2f54f9286..8cc77b3ee7 100644--- a/server/src/__tests__/company-skills-service.test.ts+++ b/server/src/__tests__/company-skills-service.test.ts@@ -89,4 +89,11 @@ describeEmbeddedPostgres("companySkillService.list", () => {editable: true,});});++ it("rejects skill inventory refresh for a missing company", async () => {+ await expect(svc.list(randomUUID())).rejects.toMatchObject({+ status: 404,+ message: "Company not found",+ });+ });});diff --git a/server/src/services/company-skills.ts b/server/src/services/company-skills.tsindex 8c67a0c3a1..0f5af2db4b 100644--- a/server/src/services/company-skills.ts+++ b/server/src/services/company-skills.ts@@ -4,7 +4,7 @@ import path from "node:path";import { fileURLToPath } from "node:url";import { and, asc, eq } from "drizzle-orm";import type { Db } from "@paperclipai/db";-import { companySkills } from "@paperclipai/db";+import { companies, companySkills } from "@paperclipai/db";import { readPaperclipSkillSyncPreference } from "@paperclipai/adapter-utils/server-utils";import type { PaperclipSkillEntry } from "@paperclipai/adapter-utils/server-utils";import type {@@ -1610,6 +1610,14 @@ export function companySkillService(db: Db) {}const refreshPromise = (async () => {+ const companyExists = await db+ .select({ id: companies.id })+ .from(companies)+ .where(eq(companies.id, companyId))+ .then((rows) => rows.length > 0);+ if (!companyExists) {+ throw notFound("Company not found");+ }await ensureBundledSkills(companyId);await pruneMissingLocalPathSkills(companyId);})();