-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
π fix: fix file upload issue #11122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts file upload size determination to fall back gracefully when metadata lookup fails and enforces a minimum file size of 1 byte before creating the file record. Sequence diagram for updated file upload size determinationsequenceDiagram
participant Client
participant FileRouter
participant FileService
participant FileModel
Client->>FileRouter: uploadFile(url, size)
FileRouter->>FileService: getFileMetadata(url)
alt metadata lookup succeeds
FileService-->>FileRouter: contentLength
alt contentLength >= 1
FileRouter->>FileRouter: actualSize = contentLength
else contentLength < 1
FileRouter->>FileRouter: actualSize = input size
end
else metadata lookup fails
FileService-->>FileRouter: error
FileRouter->>FileRouter: actualSize = input size
end
alt actualSize < 1
FileRouter-->>Client: TRPCError BAD_REQUEST
else actualSize >= 1
FileRouter->>FileModel: create(fileRecord with actualSize)
FileModel-->>FileRouter: created file id
FileRouter-->>Client: success with file id
end
Class diagram for file upload router and servicesclassDiagram
class FileRouter {
+uploadFile(url, size)
}
class FileService {
+getFileMetadata(url) contentLength
}
class FileModel {
+create(fileRecord) id
}
FileRouter --> FileService : uses
FileRouter --> FileModel : creates fileRecord
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- The silent catch around
getFileMetadatamakes it hard to debug metadata failures; consider at least logging or tagging the error path so operators can distinguish genuine tiny files from metadata lookup issues. - The fallback to
input.sizeassumes it is always defined and trustworthy; if this comes from the client, consider validating it (e.g., non-negative, reasonable upper bound) or making the type/constraints explicit to avoid abuse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The silent catch around `getFileMetadata` makes it hard to debug metadata failures; consider at least logging or tagging the error path so operators can distinguish genuine tiny files from metadata lookup issues.
- The fallback to `input.size` assumes it is always defined and trustworthy; if this comes from the client, consider validating it (e.g., non-negative, reasonable upper bound) or making the type/constraints explicit to avoid abuse.
## Individual Comments
### Comment 1
<location> `src/server/routers/lambda/file.ts:73-74` </location>
<code_context>
+ if (contentLength >= 1) {
+ actualSize = contentLength;
+ }
+ } catch {
+ // If metadata fetch fails, use original size from input
+ }
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Empty catch may hide unexpected failures in metadata lookup
Swallowing all exceptions here means configuration, permission, or `fileService` outages will be silently masked by falling back to `input.size`, which may be wrong and hard to diagnose. Please either log failures (e.g., debug/warn) or restrict the catch to the specific, expected error types so operational issues remain visible without changing user-facing behavior.
</issue_to_address>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
| } catch { | ||
| // If metadata fetch fails, use original size from input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Empty catch may hide unexpected failures in metadata lookup
Swallowing all exceptions here means configuration, permission, or fileService outages will be silently masked by falling back to input.size, which may be wrong and hard to diagnose. Please either log failures (e.g., debug/warn) or restrict the catch to the specific, expected error types so operational issues remain visible without changing user-facing behavior.
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #11122 +/- ##
========================================
Coverage 77.59% 77.60%
========================================
Files 1120 1120
Lines 84379 84404 +25
Branches 11191 10781 -410
========================================
+ Hits 65476 65503 +27
+ Misses 18903 18901 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
|
β€οΈ Great PR @arvinxx β€οΈ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
## [Version 2.0.0-next.197](v2.0.0-next.196...v2.0.0-next.197) <sup>Released on **2026-01-03**</sup> #### β» Code Refactoring - **misc**: Remove client db and refactor test. #### π Bug Fixes - **misc**: Fix file upload issue. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Remove client db and refactor test, closes [#11123](#11123) ([bb2799d](bb2799d)) #### What's fixed * **misc**: Fix file upload issue, closes [#11122](#11122) ([1ae327a](1ae327a)) </details> <div align="right"> [](#readme-top) </div>
|
π This PR is included in version 2.0.0-next.197 π The release is available on: Your semantic-release bot π¦π |
## [Version 1.148.0](v1.147.0...v1.148.0) <sup>Released on **2026-01-05**</sup> #### β» Code Refactoring - **redis**: Disable automatic deserialization in upstash provider. - **utils**: Remove unused geo server utilities. - **misc**: Refactor and fix model runtime initialize, refactor to remove access code, remove client db and refactor test. #### β¨ Features - **misc**: Add new provider Xiaomi MiMo, add work path for local system, update the sandbox export files & save files way. #### π Bug Fixes - **electron**: Correct next config codemod pattern matching. - **gtd**: Fix frozen object mutation in updateTodos. - **model-runtime**: Handle array content in anthropic assistant messages, handle incremental tool call chunks in Qwen stream, handle Qwen tool_calls without initial arguments. - **misc**: Add lost like button in discover detail page, Auto jump to group, filter empty assistant messages for Anthropic API, fix data inconsistency in ai provider config, fix editor modal when Markdown rendering off, fix file upload issue, fix tool call message content missing, restore window position safely, restore window resizable before hard reload in desktop onboarding, slove the old agents open profiles error problem, support thoughtSignature for openrouter, update CI bun version to v1.2.4, use configured embedding provider instead of hardcoded OpenAI, when the document filetype is agent/plan, not show the saveinto docs button. #### π Styles - **misc**: Update i18n, update i18n, update i18n. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **redis**: Disable automatic deserialization in upstash provider, closes [lobehub#11210](https://github.com/jaworldwideorg/OneJA-Bot/issues/11210) ([eb5c76c](eb5c76c)) * **utils**: Remove unused geo server utilities, closes [lobehub#11243](https://github.com/jaworldwideorg/OneJA-Bot/issues/11243) ([ee474cc](ee474cc)) * **misc**: Refactor and fix model runtime initialize, closes [lobehub#11134](https://github.com/jaworldwideorg/OneJA-Bot/issues/11134) ([8078cb9](8078cb9)) * **misc**: Refactor to remove access code, closes [lobehub#11120](https://github.com/jaworldwideorg/OneJA-Bot/issues/11120) ([0e9f98c](0e9f98c)) * **misc**: Remove client db and refactor test, closes [lobehub#11123](https://github.com/jaworldwideorg/OneJA-Bot/issues/11123) ([bb2799d](bb2799d)) #### What's improved * **misc**: Add new provider Xiaomi MiMo, closes [lobehub#10834](https://github.com/jaworldwideorg/OneJA-Bot/issues/10834) ([62f7858](62f7858)) * **misc**: Add work path for local system, closes [lobehub#11128](https://github.com/jaworldwideorg/OneJA-Bot/issues/11128) ([d8deadd](d8deadd)) * **misc**: Update the sandbox export files & save files way, closes [lobehub#11249](https://github.com/jaworldwideorg/OneJA-Bot/issues/11249) ([039b0a1](039b0a1)) #### What's fixed * **electron**: Correct next config codemod pattern matching, closes [lobehub#11228](https://github.com/jaworldwideorg/OneJA-Bot/issues/11228) ([06cb019](06cb019)) * **gtd**: Fix frozen object mutation in updateTodos, closes [lobehub#11184](https://github.com/jaworldwideorg/OneJA-Bot/issues/11184) ([4970794](4970794)) * **model-runtime**: Handle array content in anthropic assistant messages, closes [lobehub#11206](https://github.com/jaworldwideorg/OneJA-Bot/issues/11206) ([b03845d](b03845d)) * **model-runtime**: Handle incremental tool call chunks in Qwen stream, closes [lobehub#11219](https://github.com/jaworldwideorg/OneJA-Bot/issues/11219) ([03b9407](03b9407)) * **model-runtime**: Handle Qwen tool_calls without initial arguments, closes [lobehub#11211](https://github.com/jaworldwideorg/OneJA-Bot/issues/11211) ([5321d91](5321d91)) * **misc**: Add lost like button in discover detail page, closes [lobehub#11182](https://github.com/jaworldwideorg/OneJA-Bot/issues/11182) ([41215d4](41215d4)) * **misc**: Auto jump to group, closes [lobehub#11187](https://github.com/jaworldwideorg/OneJA-Bot/issues/11187) ([e43578a](e43578a)) * **misc**: Filter empty assistant messages for Anthropic API, closes [lobehub#11129](https://github.com/jaworldwideorg/OneJA-Bot/issues/11129) ([7af750b](7af750b)) * **misc**: Fix data inconsistency in ai provider config, closes [lobehub#11198](https://github.com/jaworldwideorg/OneJA-Bot/issues/11198) ([f8346f2](f8346f2)) * **misc**: Fix editor modal when Markdown rendering off, closes [lobehub#11251](https://github.com/jaworldwideorg/OneJA-Bot/issues/11251) ([eb86d3b](eb86d3b)) * **misc**: Fix file upload issue, closes [lobehub#11122](https://github.com/jaworldwideorg/OneJA-Bot/issues/11122) ([1ae327a](1ae327a)) * **misc**: Fix tool call message content missing, closes [lobehub#11116](https://github.com/jaworldwideorg/OneJA-Bot/issues/11116) ([885964e](885964e)) * **misc**: Restore window position safely ([e0b555e](e0b555e)) * **misc**: Restore window resizable before hard reload in desktop onboarding, closes [lobehub#11144](https://github.com/jaworldwideorg/OneJA-Bot/issues/11144) ([2516874](2516874)) * **misc**: Slove the old agents open profiles error problem, closes [lobehub#11204](https://github.com/jaworldwideorg/OneJA-Bot/issues/11204) ([7d650b6](7d650b6)) * **misc**: Support thoughtSignature for openrouter, closes [lobehub#11117](https://github.com/jaworldwideorg/OneJA-Bot/issues/11117) ([bf5d41e](bf5d41e)) * **misc**: Update CI bun version to v1.2.4, closes [lobehub#11232](https://github.com/jaworldwideorg/OneJA-Bot/issues/11232) ([dd022d5](dd022d5)) * **misc**: Use configured embedding provider instead of hardcoded OpenAI, closes [lobehub#11133](https://github.com/jaworldwideorg/OneJA-Bot/issues/11133) ([503c3eb](503c3eb)) * **misc**: When the document filetype is agent/plan, not show the saveinto docs button, closes [lobehub#11227](https://github.com/jaworldwideorg/OneJA-Bot/issues/11227) ([3a22f32](3a22f32)) #### Styles * **misc**: Update i18n, closes [lobehub#11213](https://github.com/jaworldwideorg/OneJA-Bot/issues/11213) ([00e0980](00e0980)) * **misc**: Update i18n, closes [lobehub#11145](https://github.com/jaworldwideorg/OneJA-Bot/issues/11145) ([fdadef2](fdadef2)) * **misc**: Update i18n, closes [lobehub#11115](https://github.com/jaworldwideorg/OneJA-Bot/issues/11115) ([072e0dd](072e0dd)) </details> <div align="right"> [](#readme-top) </div>
π» Change Type
π Related Issue
π Description of Change
π§ͺ How to Test
πΈ Screenshots / Videos
π Additional Information
Summary by Sourcery
Bug Fixes: