sourcegraph / src-cli

Sourcegraph CLI
https://sourcegraph.com
Apache License 2.0
267 stars 57 forks source link

codeintel: Provide hint on auth error #1079

Closed varungandhi-src closed 1 month ago

varungandhi-src commented 1 month ago

Fixes https://linear.app/sourcegraph/issue/GRAPH-579/print-warning-on-unusual-syntax-for-src-access-token

Test plan

Manually tested against HEAD.

❯ SRC_ENDPOINT=https://sourcegraph.test:3443 ~/Code/src-cli/src code-intel upload
💡 Inferred arguments
   repo: github.com/sourcegraph/conc
   commit: 5f936abd7ae87036af1f75c95fb9d0daaf00116b
   root:
   file: index.scip
   indexer: scip-go
   indexerVersion: 0.1

✅ Index compressed
💡 Indexed compressed (0.38MB -> 0.05MB).
❌ Failed to upload index file
invalid token format

A Sourcegraph access token must be provided via SRC_ACCESS_TOKEN for uploading SCIP/LSIF data.
For more details, see https://sourcegraph.com/docs/cli/how-tos/creating_an_access_token.
❯ SRC_ACCESS_TOKEN=foobar SRC_ENDPOINT=https://sourcegraph.test:3443 ~/Code/src-cli/src code-intel upload
💡 Inferred arguments
   repo:
   commit:
   root:
   file: index.scip
   indexer:
   indexerVersion:

invalid token format

A Sourcegraph access token must be provided via SRC_ACCESS_TOKEN for uploading SCIP/LSIF data.
However, the provided access token does not match expected format; was it truncated?
Typically the access token looks like sgp_<40 hex chars> or sgp_<instance-id>_<40 hex chars>.
For more details, see https://sourcegraph.com/docs/cli/how-tos/creating_an_access_token.
varungandhi-src commented 1 month ago

There is a test failure due to a data race which is unrelated to this patch. Run go test ./... locally works OK, so I'm going to merge this. 😐

bahrmichael commented 1 month ago

There is a test failure due to a data race which is unrelated to this patch. Run go test ./... locally works OK, so I'm going to merge this. 😐

That's okay with me. The data race seems to come from tests using reflection for mocking, and production code doing other stuff. There appears to be no data race within the production code, only between test and production code. I traced the data race back to https://github.com/sourcegraph/src-cli/commit/ad1b36ada775f09561eb708657f447c3c7754433#diff-0a603732f0f49068408f58001aca08acd789cc8f3c1abb75db951824fe681ca5.