Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🚈 fix: Bound Git Identity Email Validation (#17389)
lia-by-librechat[bot]a7e4de8c82ca
diff --git a/packages/api/src/agents/validation.spec.ts b/packages/api/src/agents/validation.spec.tsindex d2b4266b40..26cbd87ea9 100644--- a/packages/api/src/agents/validation.spec.ts+++ b/packages/api/src/agents/validation.spec.ts@@ -48,6 +48,31 @@ describe('agent Git identity validation', () => {expect(agentCreateSchema.safeParse({ ...base, git_identity }).success).toBe(false);});+ it.each(['create', 'update'] as const)(+ 'rejects an oversized git email on %s without passing it to a regex',+ (operation) => {+ const schema = operation === 'create' ? agentCreateSchema : agentUpdateSchema;+ const email = `1+${'a'.repeat(128_000)}!`;+ const regexCheck = jest.spyOn(RegExp.prototype, 'test');++ const result = schema.safeParse({ ...base, git_identity: { name: 'Lia', email } });+ const regexCheckedEmail = regexCheck.mock.calls.some(([value]) => value === email);+ regexCheck.mockRestore();++ expect(result.success).toBe(false);+ if (!result.success) {+ expect(result.error.issues).toContainEqual(+ expect.objectContaining({+ code: 'too_big',+ maximum: 254,+ path: ['git_identity', 'email'],+ }),+ );+ }+ expect(regexCheckedEmail).toBe(false);+ },+ );+it('accepts null only when updating to clear a configured identity', () => {expect(agentCreateSchema.safeParse({ ...base, git_identity: null }).success).toBe(false);expect(agentUpdateSchema.parse({ git_identity: null })).toEqual({ git_identity: null });diff --git a/packages/data-provider/src/types/agents.spec.ts b/packages/data-provider/src/types/agents.spec.tsindex 779c87d198..1bb43b76b0 100644--- a/packages/data-provider/src/types/agents.spec.ts+++ b/packages/data-provider/src/types/agents.spec.ts@@ -13,7 +13,54 @@ describe('agentGitIdentitySchema', () => {).toBe(true);});+ it.each(['a', 'ab', 'a-b', 'a--b', '0', 'Lia-By-LibreChat'])(+ 'accepts a bot name with valid boundaries: %s',+ (name) => {+ expect(+ agentGitIdentitySchema.safeParse({+ name: 'Lia',+ email: `1+${name}[bot]@users.noreply.github.com`,+ }).success,+ ).toBe(true);+ },+ );++ it('accepts and trims a bot address at the 254-character limit', () => {+ const suffix = '[bot]@users.noreply.github.com';+ const email = `1+${'a'.repeat(254 - 2 - suffix.length)}${suffix}`;+ expect(agentGitIdentitySchema.parse({ name: ' Lia ', email: ` ${email} ` })).toEqual({+ name: 'Lia',+ email,+ });+ });++ it.each([255, 128_003])(+ 'rejects a %i-character email before either email validator runs',+ (length) => {+ const email = `1+${'a'.repeat(length - 3)}!`;+ const regexCheck = jest.spyOn(RegExp.prototype, 'test');++ const result = agentGitIdentitySchema.safeParse({ name: 'Lia', email });+ const regexCheckedEmail = regexCheck.mock.calls.some(([value]) => value === email);+ regexCheck.mockRestore();++ expect(result.success).toBe(false);+ if (!result.success) {+ expect(result.error.issues).toContainEqual(+ expect.objectContaining({ code: 'too_big', maximum: 254, path: ['email'] }),+ );+ }+ expect(regexCheckedEmail).toBe(false);+ },+ );+it.each([+ '1+[bot]@users.noreply.github.com',+ '1+-a[bot]@users.noreply.github.com',+ '1+a-[bot]@users.noreply.github.com',+ '1+a_b[bot]@users.noreply.github.com',+ '1+a\0[bot]@users.noreply.github.com',+ '1+a\r[bot]@users.noreply.github.com','lia-by-librechat[bot]@users.noreply.github.com','328778573+lia-by-librechat[bot]@example.com','328778573+lia-by-librechat[bot]@users.noreply.github.com\nInjected',diff --git a/packages/data-provider/src/types/agents.ts b/packages/data-provider/src/types/agents.tsindex 40af340a87..86aa93a2c0 100644--- a/packages/data-provider/src/types/agents.ts+++ b/packages/data-provider/src/types/agents.ts@@ -1038,7 +1038,7 @@ export type AgentGitIdentity = {// GitHub App bot noreply addresses contain `[bot]`, which Zod's email validator rejects.const githubAppBotEmail =- /^\d+\+[a-z0-9]+(?:[a-z0-9-]*[a-z0-9])?\[bot\]@users\.noreply\.github\.com$/i;+ /^\d+\+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\[bot\]@users\.noreply\.github\.com$/i;const standardGitEmail = z.string().email();export const agentGitIdentitySchema: z.ZodType<AgentGitIdentity | undefined> = z@@ -1055,6 +1055,8 @@ export const agentGitIdentitySchema: z.ZodType<AgentGitIdentity | undefined> = z.max(254).refine((value) =>+ // Zod still runs refinements after .max() fails.+ value.length <= 254 &&!/[\0\r\n]/.test(value) &&(standardGitEmail.safeParse(value).success || githubAppBotEmail.test(value)),),