axiomhq / cli

The power of Axiom on the command line.
https://axiom.co
MIT License
42 stars 11 forks source link

"cannot decode" error for all commands #207

Closed cdjames closed 7 months ago

cdjames commented 8 months ago

All commands are failing with error "cannot decode response with unknown content type". Installed with brew install axiom

~ % axiom stream clavis-demo
! Organization ID is set using "AXIOM_ORG_ID"!
! Token is set using "AXIOM_TOKEN"!
! URL is set using "AXIOM_URL"!
Error: cannot decode response with unknown content type
~ % axiom auth status
! Organization ID is set using "AXIOM_ORG_ID"!
! Token is set using "AXIOM_TOKEN"!
! URL is set using "AXIOM_URL"!
➜ cloud
    ✖ cannot decode response with unknown content type

~/.zprofile:

export AXIOM_TOKEN="{redacted}"
export AXIOM_URL="https://app.axiom.co"
export AXIOM_ORG_ID="clavis-vsr2"
export AXIOM_DEPLOYMENT="cloud"

Shell: zsh OS: macOS 12.7.2 Go version: go1.21.6 darwin/arm64 Brew version: 4.2.5 Axiom CLI version: 0.12.0 (revision: c70256c)

lukasmalkmus commented 8 months ago

Hi!

AXIOM_URL should point to our API, e.g. api.axiom.co instead of app.axiom.co.

Can you double check and report back here?

Cheers!

cdjames commented 8 months ago

Hi!

AXIOM_URL should point to our API, e.g. api.axiom.co instead of app.axiom.co.

Can you double check and report back here?

Cheers!

Thanks for the tip, but unfortunately changing the URL gives the same result:

image

By the way, this is where I got the original URL.

image
lukasmalkmus commented 8 months ago

Thanks for the tip, but unfortunately changing the URL gives the same result:

That is interesting. I just re-ran a couple of tests for our API and that worked flawlessly. I'll investigate further...

By the way, this is where I got the original URL.

Duh! Thanks for letting us know! /cc @thecraftman Can you update our docs?

@cdjames Could you back up any config files or env vars and start from a blank state? How does running axiom auth login work for you?

cdjames commented 8 months ago

@cdjames Could you back up any config files or env vars and start from a blank state? How does running axiom auth login work for you?

I'm able to run commands after I manually login using axiom auth login. However, I was hoping to avoid that since it's annoying to check my email to log in.

image

I think I figured it out; after I added the "active_deployment" line to my .axiom.toml file (based on the file created when axiom auth login was run, I was able to connect without a manual login. I think that might be something that's missing from the online documentation.

active_deployment = "axiom"

[deployments]

  [deployments.axiom]
    url = "https://api.axiom.co/"
    token = "xapt-XXXX"
    org_id = "clavis-vsr2"
lukasmalkmus commented 8 months ago

Remember you only need to be logged in once as the credentials are persisted in ~/.axiom.toml. But if you prefer to use environment variables, that is totally fine, too.

I think you stumbled across a bug here: If CLI is explicitly configured via the environment, the active_deployment should be ignored. The active_deployment is only there to persist the chosen environment/deployment and in most cases there is only one.

I'll leave this issue open as there are definitely some takeaways from this.

thecraftman commented 8 months ago

thanks @cdjames i will update the docs and get this issue fixed.

lukasmalkmus commented 8 months ago

@cdjames I just double checked some of your reports and I wonder: It sounds like you had a ~/.axiom.toml present and environment variables? Ideally, you get rid of the config file if you don't plan on utilising that. If the env vars are present, it uses those. That should work for you without needing to wait of a fix. Also no need to set AXIOM_DEPLOYMENT.

I'll make sure docs get updated.

lukasmalkmus commented 8 months ago

@thecraftman Do you think we should get rid of the Sessions section? https://axiom.co/docs/reference/cli#session-support. I think it is a bit confusing. Most people won't use more than one deployment. Switching between orgs is possible via axiom auth switch-org or just setting AXIOM_ORG_ID.

We should probably highlight that a good starting point is logging in via CLI (axiom auth login or just running axiom when there is no config present) OR explicitly configuring via the environment, with credentials taken from the Profile page on the App. And in that later case also hint at the correct API url.

IMHO, the config file shouldn't be documented explicitly as it isn't intended to be edited manually for nearly all use cases.

thecraftman commented 8 months ago

@lukasmalkmus yeah awesome we need to specify that in the docs, and when to work with the active deployments per session support specifying axiom auth login and axiom commands. If the user has multiple environments we need to add how they can configure that as well using the API url

thecraftman commented 8 months ago

thanks @cdjames a fix for this is on the way.

cdjames commented 8 months ago

Ideally, you get rid of the config file if you don't plan on utilising that. If the env vars are present, it uses those.

@lukasmalkmus This is what I see if I get rid of the deployment file and try a command

image

Then if I replace the deployment file, the command works:

image

The token is the same in both cases.

lukasmalkmus commented 7 months ago

@cdjames Ah I see. Should have been more specific: You should be able to run all other commands, e.g. axiom stream, axiom ingest, everything under the axion dataset command without a problem.

axiom auth is indeed special as it operates directly on the configuration file, not caring about the env setup.

thecraftman commented 7 months ago

@cdjames thanks the documentation for this has been updated here: https://axiom.co/docs/reference/cli

lukasmalkmus commented 7 months ago

Feel free to re-open or add a new issue if you have more questions, as the original cannot decode error was caused by setting the wrong API url. We improved the documentation on that.