sourcegraph / src-cli

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

codeintel: Provide hint on auth error #1078

Closed sourcegraph-bot closed 1 month ago

sourcegraph-bot 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.
sourcegraph-bot commented 1 month ago

Oops, created this with bot account instead of personal account.