-
Notifications
You must be signed in to change notification settings - Fork 27
After a successful upload, the generateId is no return #44
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
base: main
Are you sure you want to change the base?
Conversation
[Better Auth]: [Drizzle Adapter] - You are trying to create a record with an id. This is not allowed as we handle id generation for you. The id will be ignored.
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.
Pull Request Overview
This PR addresses a warning from the Drizzle Adapter by removing the manual ID setting when creating database records during file uploads. The adapter auto-generates IDs and rejects manual ID specification.
Key changes:
- Removed explicit
idfield fromadapter.create()call during file upload - Captured the returned database record to access the adapter-generated ID
- Updated response to use the new database-generated ID instead of the pre-generated one
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // You are trying to create a record with an id. | ||
| // This is not allowed as we handle id generation for you. | ||
| // The id will be ignored. | ||
| // id: fileMetadata.id, |
Copilot
AI
Nov 11, 2025
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.
This multi-line comment explaining why the ID is commented out should be removed. Commented-out code with explanatory notes is typically not appropriate for production code. If the ID field should not be set, it should simply be omitted rather than left as a commented line with an explanation.
Consider removing lines 651-654 entirely.
| // You are trying to create a record with an id. | |
| // This is not allowed as we handle id generation for you. | |
| // The id will be ignored. | |
| // id: fileMetadata.id, |
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.
this would need to be removed, yes
|
Hi @MagnumGoYB ! Sorry for delay busy work week will check this out during the weekend! |
|
Hi @MagnumGoYB - thanks again for your contribution! There are a few more things to consider about this change: The file id set from the metadata comes from the process of storing in R2 - the file id in R2 and the file id in D1 are meant to match. We could switch the order of the calls (store metadata in D1, then store file in R2) so that drizzle id is made first, then use that drizzle id in the R2 upload. But that ordering of calls is not the best design in my opinion - you would need to consider rolling back D1 inserts if the R2 upload failed to keep things synced. Open to more feedback, I could be convinced otherwise :) |

Removed the manual setting of id when creating records via the Drizzle Adapter to prevent the following warning: