Skip to content
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

🐛 Bug Report: The avatars commands giving Error: Not Found #86

Open
2 tasks done
ra-jeev opened this issue Jul 8, 2023 · 7 comments
Open
2 tasks done

🐛 Bug Report: The avatars commands giving Error: Not Found #86

ra-jeev opened this issue Jul 8, 2023 · 7 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ra-jeev
Copy link

ra-jeev commented Jul 8, 2023

👟 Reproduction steps

appwrite avatars --verbose getFlag --code af --destination test.png

👍 Expected behavior

Should download the flag icon and create a new file at the destination path.

👎 Actual Behavior

Throws the below error:

AppwriteException [Error]: Not Found
    at Client.call (/usr/local/lib/node_modules/appwrite-cli/lib/client.js:209:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async avatarsGetFlag (/usr/local/lib/node_modules/appwrite-cli/lib/commands/avatars.js:144:22) {
  code: 404,
  response: [Object: null prototype] {
    message: 'Not Found',
    code: 404,
    type: 'general_route_not_found',
    version: '0.10.44'
  }
}

Error Not Found

🎲 Appwrite version

Appwrite CLI v2.0.2

💻 Operating system

macOS v12.6.7

🧱 Your Environment

Using the appwrite CLI v2.0.2 on macbook pro with zsh.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@ra-jeev ra-jeev added the bug Something isn't working label Jul 8, 2023
@ra-jeev ra-jeev changed the title 🐛 Bug Report: 🐛 Bug Report: The avatars commands giving Error: Not Found Jul 8, 2023
@stnguyen90
Copy link
Contributor

@ra-jeev thanks for raising this issue! 🙏🏼 Looks like there are a few things wrong with how we handle images in the CLI:

  1. The endpoint is included in the path when it shouldn't be:

path = `${globalConfig.getEndpoint()}${path}?${queryParams.toString()}`;

  1. The content-type is set to application/json:

'content-type': 'application/json',

  1. The transformResponse tries to parse the data when it shouldn't:

transformResponse: [ (data) => data ? JSONbig.parse(data) : data ],

@stnguyen90 stnguyen90 added good first issue Good for newcomers help wanted Extra attention is needed labels Aug 2, 2023
@ra-jeev
Copy link
Author

ra-jeev commented Aug 3, 2023

@stnguyen90 Thanks a lot for acknowledging the issue. Glad I was able to notice this bug while playing around with the appwrite CLI (actually I was trying to connect Appwrite CLI to the 1Password CLI, and that is when I noticed it).

@adarshjhaa100
Copy link

Hi, I can work on this if no one's working on this

@stnguyen90
Copy link
Contributor

@adarshjhaa100, are you still interested in working on this?

@stnguyen90 stnguyen90 self-assigned this Sep 22, 2023
@adarshjhaa100
Copy link

@stnguyen90 yes I am interested. Just confirming, need to raise PR to the SDK Generator repo right ?

@stnguyen90
Copy link
Contributor

@adarshjhaa100, assigned! Yes, the SDK Generator repo, please.

@adarshjhaa100
Copy link

@stnguyen90 Looks like something's changed. The latest version gives a slightly different issue:
image

The 1st and 3rd point you've mentioned seems a correct analysis of the issue. I made the change and am able to download the image:
image

Would like to add something for the 2nd point here. This is a GET request, which has a null request body. So, it seems fair to omit the content-type from request header while fetching avatar. (I presume content-type here is the type of request body, correct me if im wrong)

Given the above analysis, just need to figure out how to handle for images.

Couple of solutions which I can think of:

  1. Probably can use the response header content-type to identify and then apply appropriate transformResponse. But I don't see a way to pull responseHeader in the request config.

  2. I see that responseType of 'arraybuffer' is used for avatars only. So, could use that to change the transformResponse.

Do let me know if either of these seem feasible. I'll raise a PR post that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants