Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: handle missing employee job record
Brad Barbin8421b25ec3fd
diff --git a/packages/integrations/src/slack/lib/client.ts b/packages/integrations/src/slack/lib/client.tsindex 17f03bf235..608cc7da3e 100644--- a/packages/integrations/src/slack/lib/client.ts+++ b/packages/integrations/src/slack/lib/client.ts@@ -33,6 +33,7 @@ export const slackOAuthTokenResponseSchema = z.object({id: z.string(),name: z.string(),}),+// incoming_webhook is only present when the app has incoming-webhook scopeincoming_webhook: z.object({diff --git a/packages/integrations/src/slack/lib/service.ts b/packages/integrations/src/slack/lib/service.tsindex d7388c366f..f36437ffc6 100644--- a/packages/integrations/src/slack/lib/service.ts+++ b/packages/integrations/src/slack/lib/service.ts@@ -297,35 +297,24 @@ export async function getCarbonEmployeeFromSlackId(carbonCompanyId: string) {try {- console.log({- function: "getCarbonEmployeeFromSlackId",- accessToken,- slackUserId,- carbonCompanyId,- });const slackClient = createSlackWebClient({ token: accessToken });const userInfo = await slackClient.users.info({user: slackUserId,});- console.log({- userInfo,- });-if (!userInfo.ok || !userInfo.user?.profile?.email) {return { data: null, error: "Could not retrieve user email from Slack" };}const email = userInfo.user.profile.email;- console.log({ email });-const user = await client.from("user").select("id").eq("email", email).single();+if (user.error || !user.data?.id) {const location = await client.from("location")@@ -339,12 +328,28 @@ export async function getCarbonEmployeeFromSlackId(error: null,};}- return client+ const job = await client.from("employeeJob").select("*").eq("id", user.data.id).eq("companyId", carbonCompanyId)- .single();+ .maybeSingle();++ if (job.error || !job.data?.id) {+ const location = await client+ .from("location")+ .select("id")+ .eq("companyId", carbonCompanyId);+ return {+ data: {+ id: user.data.id,+ locationId: location.data?.[0]?.id,+ },+ error: null,+ };+ }++ return job;} catch (error) {console.error("Error getting Carbon employee from Slack ID:", error);return {