ZachHandley / AppwriteUtils

Migrations code for Appwrite
25 stars 1 forks source link

Error during retryAwait function: TypeError: Invalid URL #6

Open AlbertoBonfiglio opened 2 months ago

AlbertoBonfiglio commented 2 months ago

Hello, I have installed the latest appwrite (6.0) and appwirite-util cli globally I have a valid appwrite.json in the root directory of my project I am logged in the development server at http:localhost/v1 I set up an appwriteConfig.ts with endpoint, projectId and key, I added the database the config file

`  databases: [
    {
      "$id": "main",
      "name": "main",
    }
  ],`

when I run npx --package=appwrite-utils-cli@latest appwrite-migrate --it and select sync or any other option except setup local directories it gives me the following error:


Error during retryAwait function: TypeError: Invalid URL
An error occurred: TypeError: Cannot read properties of undefined (reading 'databases')
    at fetchAllDatabases (file:///home/darthbert/.npm/_npx/3b529e35b3368a11/node_modules/appwrite-utils-cli/dist/migrations/databases.js:8:36)
    at async UtilsController.syncDb (file:///home/darthbert/.npm/_npx/3b529e35b3368a11/node_modules/appwrite-utils-cli/dist/utilsController.js:163:27)
    at async InteractiveCLI.syncDb (file:///home/darthbert/.npm/_npx/3b529e35b3368a11/node_modules/appwrite-utils-cli/dist/interactiveCLI.js:325:9)
    at async InteractiveCLI.run (file:///home/darthbert/.npm/_npx/3b529e35b3368a11/node_modules/appwrite-utils-cli/dist/interactiveCLI.js:58:21)
    at async main (file:///home/darthbert/.npm/_npx/3b529e35b3368a11/node_modules/appwrite-utils-cli/dist/main.js:133:9)

Any idea of what's happening?

AlbertoBonfiglio commented 2 months ago

After troubleshooting I found I can make it work by returning config.default instead of config from loadConfig in loadConfig.js. Do you see a problem with this? I didn't have time to study the code extensively sto see if it may causes side effects. I am submitting a PR for your review.