axiomhq / cli

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

Missing OrganizationID when using Personal Access Token with cloud deployment #116

Closed a-khaledf closed 2 years ago

a-khaledf commented 2 years ago

I have dug around the https://github.com/axiomhq/axiom-go to figure out why it returned Error: missing organization id when initializing the client in the cli code and I found the following comment:

// When the organization ID is not set, use `AXIOM_ORG_ID`. In case the url
// is the Axiom Cloud url and the access token is a personal token, the
// organization ID is explicitly required and an error is returned, if it is
// not set.

The cli usage documentation doesn't show that explicit requirement and the demo also doesn't show the setting of AXIOM_ORG_ID.

lukasmalkmus commented 2 years ago

Thanks for the report @a-khaledf!

Yes, demo GIF is outdated! Needs to be updated at some point.

Can you eloborate what you mean by cli usage documentation? Where should we add the hint in your opinion?

a-khaledf commented 2 years ago

@lukasmalkmus I think if the cli won't work with specific environment variables it should be explicitly mentioned in the readme file in Github. in my situation maybe it is an old version but I had to dig down the code of the cli and axiom-go to figure out why it is not working and I found the above comment in the axiom-go code which explained that i might need to set AXIOM_ORG_ID

lukasmalkmus commented 2 years ago

Ah, yes. But it sounds like your issue was the other way around! Maybe AXIOM_URL was set to something and automatically picked up by cli?

But yeah, we should probably put that somewhere in the README, that it auto loads AXIOM_ envs.

a-khaledf commented 2 years ago

The issue I had was that the prompt failed to get the organization Id automatically after providing a personal access token since it was needed in axiom-go client initialization, and when I got into the axiom-go code it was saying that you need to set AXIOM_ORG_ID if you are using personal token. but I didn't find that documented in the cli readme

lukasmalkmus commented 2 years ago

The cli does it's own handling of env vars. axiom-go has an option for this called NoEnv(). The error you got indicates that you were using a deployment that is not cloud. When using our internal cloud development, cli does not detect that as cloud and thus not ask for the org id (which is not needed for cloud).

Try with latest release and report back if something is not working.