Commit bc865df
authored
fixes panic when api returns nil (#50)
`kernel browsers list` panics when there are no browsers to list! Fixed
and added a unit test for it 😄
I also didn't like that prod release is 4 commands so I vibed a script
to do it
**Previously**
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1025be884]
goroutine 1 [running]:
github.com/onkernel/cli/cmd.BrowsersCmd.List({{0x1029b10c8, 0x140000d2300}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
/Users/tanmaysardesai/github.com/onkernel/cli/cmd/browsers.go:222 +0x164
github.com/onkernel/cli/cmd.runBrowsersList(0x102e4a560, {0x10263262a?, 0x4?, 0x102632536?})
/Users/tanmaysardesai/github.com/onkernel/cli/cmd/browsers.go:2128 +0x2ec
github.com/spf13/cobra.(*Command).execute(0x102e4a560, {0x102e80cc0, 0x0, 0x0})
/Users/tanmaysardesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0x7d4
github.com/spf13/cobra.(*Command).ExecuteC(0x102e4ece0)
/Users/tanmaysardesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x350
github.com/spf13/cobra.(*Command).Execute(...)
/Users/tanmaysardesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
github.com/spf13/cobra.(*Command).ExecuteContext(...)
/Users/tanmaysardesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:1064
github.com/charmbracelet/fang.Execute({0x1029ae0f8, 0x102e80cc0}, 0x102e4ece0, {0x14000223e98, 0x2, 0x2?})
/Users/tanmaysardesai/go/pkg/mod/github.com/charmbracelet/[email protected]/fang.go:151 +0x320
github.com/onkernel/cli/cmd.Execute({{0x10285b4f8, 0x6}, {0x10285bce0, 0x28}, {0x10285bb50, 0x14}, {0x10285ba98, 0x8}})
/Users/tanmaysardesai/github.com/onkernel/cli/cmd/root.go:164 +0x2e8
main.main()
/Users/tanmaysardesai/github.com/onkernel/cli/cmd/kernel/main.go:17 +0x78
```
**now**
```
INFO No running browsers found
```
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Prevents a panic in `kernel browsers list` when the API returns no
page, adds a unit test, and introduces a `scripts/release.sh` with
updated release docs.
>
> - **CLI (browsers list)**
> - Safely handle `nil` page from SDK in `cmd/browsers.go` and treat as
empty results.
> - JSON output now prints `[]` when no items (`len(browsers)==0`).
> - Shows "No running browsers found" when empty instead of panicking.
> - **Tests**
> - Add `TestBrowsersList_PrintsEmptyMessagePageIsNil` in
`cmd/browsers_test.go`.
> - **Release**
> - Add `scripts/release.sh` to tag, push, and run `make release` with
basic version validation.
> - Update `DEVELOPMENT.md` to use `git describe --abbrev=0` and
`./scripts/release.sh <version> [description]` for releases.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
fe327db. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 1b043a5 commit bc865df
File tree
4 files changed
+43
-7
lines changed- cmd
- scripts
4 files changed
+43
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
| 82 | + | |
86 | 83 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | | - | |
| 228 | + | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
123 | 138 | | |
124 | 139 | | |
125 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments