Override error in React tutorial on the add userId to the database step
Before adding the userId to the schema the line
presents no problems. Once I add userId to the schema it presents the expected error. Once I push the new schema to the db this error presents:
Solution:Jump to solution
Coercing it with the following removes the problem and in theory should be fine because auth() is called in the middleware and the userId should only be empty if they fail auth correct?
...
2 Replies
Along with this error:
Oddly enough everything seems to work fine locally. Building throws an error about missing configuration for DATABASE_URL which I suspect is related to further steps in this segment of the tutorial.
So I finished that segment of the tutorial and everything builds and works but VS Code is still identifying a problem with the values parameters
It appears the error results from userId being declared as a not null varchar 256 while the clerk auth function returns a userId that can be either string or null. declaring the userId for the database insert like so fixes the problem but is clearly not the correct answer:
This doesn't seem correct though as it may allow Drizzle to create a record without an actual userId attached which we would like rejected presumably.
Solution
Coercing it with the following removes the problem and in theory should be fine because auth() is called in the middleware and the userId should only be empty if they fail auth correct?