mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
Reject stale company skill refreshes
This commit is contained in:
1 parent
15c0ce3722
commit
758ad533ca
2 files changed
+16
-1
No files matched your search
@@ -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",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
})();
|
||||
|
||||
Reference in new issue
Block a user