phrase / phrase-cli

CLI for the Phrase API
https://developers.phrase.com
MIT License
42 stars 5 forks source link

Phrase CLI returns unhelpful "ERROR: 404 Not Found" with no details #141

Closed rlundy closed 6 months ago

rlundy commented 9 months ago

I'm trying the command phrase push -w, and I get back

ERROR: 404 Not Found

If I use phrase push -w -v instead, I get more data [shown below, redacted], but still no useful error message:

>phrase push -w -v
&{Credentials:{Username: Token:[OMITTED] TFA:false TFAToken: Host:} Debug:true Page:<nil> PerPage:<nil> DefaultProjectID:[OMITTED] DefaultFileFormat: Defaults:map[] Targets:[OMITTED] Sources:[OMITTED] UserAgent:Phrase Strings CLI (2.22.0)}
ERROR: 404 Not Found

What would be more useful is an explanation of why the 404 happened. What address was I trying to reach that doesn't exist?

rlundy commented 9 months ago

I tried Fiddler to see what URL it was trying to hit and there's nothing there, even if I tell it to intercept and decrypt HTTPS. When I run the Phrase CLI, it isn't making an entry in the Fiddler list.

jablan commented 9 months ago

Hi @rlundy thanks for reporting this, the error is indeed not telling much. We will open an internal task to improve on this.

In the meantime, could you double check your project ID in your phrase.yml configuration?

rlundy commented 9 months ago

I've confirmed that the project ID is correct. Our phrase.yml file looks like this (but with the correct project ID, of course):

phrase:
  project_id: REDACTED
  push:
    sources:
      - file: ./src/assets/locales/<locale_name>.json
        params:
          file_format: i18next
  pull:
    targets:
      - file: ./src/assets/locales/<locale_name>.json
        params:
          file_format: i18next
jablan commented 9 months ago

Just to double check: a project with that ID exists on app.phrase.com (our EU app instance), not on us.app.phrase.com (or US instance)? Otherwise an appropriate API url has to be specified in the config as well.

rlundy commented 9 months ago

Correct, we're using app.phrase.com, EU data center. We're based in Switzerland.

rlundy commented 9 months ago

Doubtless worth noting is that some Phrase CLI commands do work correctly. If I use

phrase users user

for example, I do get back the details of my user.

rlundy commented 9 months ago

I also tried adding host: to the .yml file:

phrase:
  host: https://api.phrase.com/v2/
  project_id: REDACTED
  [...etc...]

But this gave me the same results; phrase users user works but phrase push -w -v gives a 404 with no other info.

jablan commented 9 months ago

@rlundy what about

phrase projects show --id ID_OF_YOUR_PROJECT

Does that work? 404 somehow still suggests that either project or locale id is wrong.

rlundy commented 9 months ago

It turns out that another employee at our company decided, without notifying anybody, to revoke the API key because he thought we should be using an API key tied to his account instead of the account it was on. With the new non-revoked API key, I can now see the project by ID.

But there's still something for Phrase to fix here.

Where an API key is invalid, it ought to be showing us a 401, not a 404. Then at least we can be barking up the right tree when we look for a fix.

rlundy commented 6 months ago

@theSoenke May I ask what the fix was?

jablan commented 6 months ago

@rlundy we couldn't reproduce your case. When I try to perform a push (or, to keep it simple, projects show) using an invalid token, I'm getting 401 (you can try that yourself, by stripping your working token the last character for example).

Your 404s suggest to me that the token was still valid, but the user owning it didn't have the access to the project in question. So, from that perspective, it's just an unknown project and 404 would be a valid response.