Skip to content

fix: use default Apollo client for AI chat file upload#18158

Merged
Weiko merged 1 commit intotwentyhq:mainfrom
a827681306:fix/ai-chat-file-upload-apollo-client
Feb 24, 2026
Merged

fix: use default Apollo client for AI chat file upload#18158
Weiko merged 1 commit intotwentyhq:mainfrom
a827681306:fix/ai-chat-file-upload-apollo-client

Conversation

@a827681306
Copy link
Copy Markdown
Contributor

Summary

Fix file uploads in AI chat (Agent Chat) failing with "Failed to upload file" for all file types.

Root Cause

useAIChatFileUpload.ts was using useApolloCoreClient() which points to the /graphql (workspace) endpoint. However, FileUploadResolver is decorated with @MetadataResolver(), meaning uploadFile is only registered on the /metadata endpoint.

Fix

Replace useApolloCoreClient() with useApolloClient() from @apollo/client, which is the default Apollo client pointing to the /metadata endpoint. This is consistent with how useUploadAttachmentFile.tsx handles file uploads.

Changes

  • Replaced useApolloCoreClient import with useApolloClient from @apollo/client
  • Updated the client variable to use the default Apollo client
  • Removed unused useApolloCoreClient import

Fixes #18153

The uploadFile mutation is registered on the /metadata endpoint (FileUploadResolver
is decorated with @MetadataResolver()), but useAIChatFileUpload was using
useApolloCoreClient() which points to the /graphql (workspace) endpoint.

This caused all file uploads in AI chat to fail with 'Failed to upload file'.

Fixes twentyhq#18153
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 22, 2026

Greptile Summary

Fixed file upload failures in AI chat by switching from useApolloCoreClient() (which points to /graphql) to useApolloClient() (which points to /metadata). Since FileUploadResolver is decorated with @MetadataResolver(), it only registers the uploadFile mutation on the /metadata endpoint. This change aligns with the pattern used in useUploadAttachmentFile.tsx.

Confidence Score: 5/5

  • Safe to merge - simple, focused bug fix with minimal code changes
  • The fix is a straightforward client replacement that addresses the root cause (endpoint mismatch). The change is consistent with existing patterns in the codebase (useUploadAttachmentFile.tsx) and has been verified against the server-side resolver configuration.
  • No files require special attention

Important Files Changed

Filename Overview
packages/twenty-front/src/modules/ai/hooks/useAIChatFileUpload.ts Correctly replaced useApolloCoreClient with useApolloClient to use the /metadata endpoint for file uploads

Last reviewed commit: 50e4adb

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@etiennejouan etiennejouan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! Thanks for your contribution

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Weiko Weiko disabled auto-merge February 24, 2026 08:54
@Weiko Weiko merged commit df196b4 into twentyhq:main Feb 24, 2026
32 of 54 checks passed
@twenty-eng-sync
Copy link
Copy Markdown

Hey @Weiko! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uploadFile mutation in AI chat uses wrong Apollo client (sends to /graphql instead of /metadata)

3 participants