Commit d88c938
authored
Fix labs panic on empty release list and make update check best-effort (#5503)
## Why
Found during a full-repo review of the CLI. Two related problems in the
`databricks labs` update check that runs before every command of an
installed project:
1. The CLI panics with an index-out-of-range error when the release list
is empty. This happens for repositories with zero GitHub releases, and
also offline: the cache falls back to an empty list when the network is
unreachable.
2. The check is fail-closed. It exists only to print an upgrade hint,
yet any error aborts the command. The unauthenticated GitHub API allows
only 60 requests per hour per IP, so a 403 from rate limiting blocks
every `databricks labs <project> ...` invocation until the quota resets.
## Changes
Before, an empty release list crashed the CLI and any update-check
failure aborted the command; now the upgrade hint is skipped and the
command runs normally in both cases.
- `cmd/labs/project/project.go`: `checkUpdates` returns early when the
loaded release list is empty instead of indexing into it.
- `cmd/labs/project/proxy.go`: a failing update check is logged at debug
level and the command proceeds, instead of returning the error.
## Test plan
- [x] New unit test `TestCheckUpdatesWithEmptyReleaseList`: panics with
"index out of range [0] with length 0" before the fix, passes after.
- [x] New test `TestRunningCommandWhenUpdateCheckFails`: runs `labs
blueprint echo` with the GitHub API returning HTTP 500; fails with
"github request failed: 500 Internal Server Error" before the fix,
passes after.
- [x] `go test ./cmd/labs/...` passes.
- [x] `./task fmt-q`, `./task lint-q`, and `./task checks` pass.
This pull request and its description were written by Isaac.1 parent a29c997 commit d88c938
4 files changed
Lines changed: 57 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments