{"record":{"id":"ae0c69c03ef2832f","repo":"different-ai/openwork","slug":"team-not-found","errorCode":"team_not_found","errorMessage":"team_not_found","messagePattern":"team_not_found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"ee/apps/den-api/src/routes/org/llm-providers.ts","lineNumber":329,"sourceCode":"  }\n\n  return memberIds\n}\n\nasync function resolveTeamIds(input: {\n  organizationId: typeof LlmProviderTable.$inferSelect.organizationId\n  values: string[]\n}) {\n  const uniqueValues = [...new Set(input.values)]\n  if (uniqueValues.length === 0) {\n    return [] as TeamId[]\n  }\n\n  const teamIds = uniqueValues.map((value) => {\n    try {\n      return parseTeamId(value)\n    } catch {\n      throw createFailure(404, \"team_not_found\")\n    }\n  })\n\n  const rows = await db\n    .select({ id: TeamTable.id })\n    .from(TeamTable)\n    .where(and(eq(TeamTable.organizationId, input.organizationId), inArray(TeamTable.id, teamIds)))\n\n  if (rows.length !== teamIds.length) {\n    throw createFailure(404, \"team_not_found\")\n  }\n\n  return teamIds\n}\n\nfunction resolveCredentialColumn(input: {\n  providerConfig: Record<string, unknown>\n  existingProvider: Pick<LlmProviderRow, \"apiKey\" | \"providerConfig\"> | null","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/routes/org/llm-providers.ts#L311-L347","documentation":"resolveTeamIds validates each team identifier with parseTeamId; a value that is not a well-formed team ID triggers an immediate 404 team_not_found failure, mirroring the member ID check but for team grants on an LLM provider.","triggerScenarios":"An org LLM provider create/update request includes a team ID string that fails parseTeamId (malformed or wrong-entity ID).","commonSituations":"Client sends a team name/slug instead of an ID; sends a member ID in the teams array; truncated or hand-edited IDs in config files or IaC templates.","solutions":["Replace the malformed value with a valid team table ID from the org's teams list endpoint.","Confirm the value is a team ID, not a slug, name, or member ID.","If stored in config/terraform, regenerate the ID from the API rather than editing by hand.","Enable request logging to see the exact offending value."],"exampleFix":"// before\n{ \"teamIds\": [\"platform-team\"] }\n// after\n{ \"teamIds\": [\"team_3d8b21f0-1a2c-4d5e-9f6a-7b8c9d0e1f2a\"] }","handlingStrategy":"validation","validationCode":"const TEAM_ID_RE = /^(team_|t_)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!values.every(v => TEAM_ID_RE.test(v))) throw new Error('malformed team id');","typeGuard":"function isTeamId(v: unknown): v is string { return typeof v === 'string' && v.length > 0 && isUuidLike(v) }","tryCatchPattern":"try { await updateProviderGrants({ teamIds }) } catch (e) { if (e.code === 'team_not_found') console.error('bad team id in payload'); }","preventionTips":["Fetch team IDs from the org teams endpoint, never hand-edit them","Keep team slugs/names out of ID fields","Validate payload shape with a schema (zod) before sending"],"tags":["http-404","validation","teams"],"backgroundTag":"resource-not-found","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}