divviup / divviup-api

Divvi Up Control Plane
https://divviup.org
Mozilla Public License 2.0
4 stars 1 forks source link

CLI fails to parse response when fetching accounts #550

Closed divergentdave closed 1 year ago

divergentdave commented 1 year ago

I was stepping through the new account creation flow on commit 281ea361c3c17c4ddca51c62c9fe58f42e249895, and I ran into an error when generating collector credentials. I ran RUST_LOG=trace cargo run -p divviup-cli -- -u http://app.example/ -t DUAT... hpke-config generate. The logs indicate that that it made a GET /api/accounts request, and got a 200 response. Following this, it printed the error message expected value at line 1 column 1 in red. (not via tracing-subscriber)

jbr commented 1 year ago

Just confirming, the -u url is the api url? And curling that reaches the api correctly?

jbr commented 1 year ago

This wouldn't surprise me if it wasn't in fact receiving json, but instead is receiving html because it's hitting the react app

divergentdave commented 1 year ago

Whoops, you were right, I should have been using -u http://api.example/.

New problem: I now get unexpected http status GET http://api.example/api/accounts Some(403): in red text.

jbr commented 1 year ago

Sounds like the api token isn't found

divergentdave commented 1 year ago

Since I'm currently using the integration test flavor of the container image, I think that's interfering with the token-based authentication. I confirmed the API token matches. If I replay the request in curl, and then tweak it by removing the Authorization header entirely, then it succeeds. To make acceptance testing easier, we could either tweak how the integration test feature works to coexist with this header, add a way to use the CLI without a token, or change our deployment to use prod-ready images and an Auth0 mock or dev tenant. I'm going to close this issue, since it stemmed from user error.