invalid args for renaming a file
when calling a function to rename a file, it says that the arguments are invalid, although I specified everything that is needed
17 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Your mutation definition is incorrect. When defining the handler, it should begin like this:
What the
mutation
function receives is an object, so args
and handler
both must be properties of that object. Your current syntax doesn't follow that pattern. Frankly I'm not sure why you didn't get an error about this.here it requires specifying the
ctx
argument, provided that in all other functions when they are called, it does not requireI don't think you understand my point. You're defining the handler like this:
...when it should look like this:
handler
needs to be a property on the object that's passed to mutation
, just as args
above it is another property in that object. Passing the function any other way won't work.OK, I change the handler for the handler method, but it still complains about the 2nd argument
How are you defining
renameFile
?
Do you have a renameFile
function defined anywhere else?Creating an arrow function
Sorry, I meant in the component where you're trying to use it.
convex/files.ts
In the file where you're seeing that error, where is
renameFile
defined?import { renameFile } from "../../../../convex/files"
Import it finds all other functions from the same file tooThat's not the correct way to use the function. You should be importing the
useMutation
hook and doing something like this:
https://docs.convex.dev/functions/mutation-functions#calling-mutations-from-clientsMutations | Convex Developer Hub
Mutations insert, update and remove data from the database, check authentication
OOPS
I called other functions using this hook, but then I forgot
No worries. It can take some time to get used to the Convex workflow.
thanks