You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use SDK RawJSON() for -o json output to avoid zero values (#69)
## Summary
- When using `-o json`, the CLI was re-marshaling SDK response structs
with `json.MarshalIndent()`, which included Go zero values for fields
not present in the API response (e.g., `deleted_at`, `persistence`,
`profile`, `viewport`)
- Now uses the SDK's `RawJSON()` method which preserves the original API
response, only outputting fields that were actually returned
- Adds `PrintPrettyJSON` and `PrintPrettyJSONSlice` helpers in
`pkg/util/json.go` that pretty-print the raw JSON from SDK response
types
### Before
```json
{
"cdp_ws_url": "wss://...",
"created_at": "2026-01-12T02:41:42.658978979Z",
"session_id": "wvmx4yt5afram2xobclje52x",
"timeout_seconds": 60,
"deleted_at": "0001-01-01T00:00:00Z",
"kiosk_mode": false,
"persistence": {"id": ""},
"profile": {"id": "", "created_at": "0001-01-01T00:00:00Z", ...},
"viewport": {"height": 0, "width": 0, "refresh_rate": 0}
}
```
### After
```json
{
"browser_live_view_url": "https://...",
"cdp_ws_url": "wss://...",
"created_at": "2026-01-12T02:49:16.736473188Z",
"headless": false,
"session_id": "tpuq0sl28j5d8par13mqo79d",
"stealth": false,
"timeout_seconds": 60
}
```
## Test plan
- [x] All existing tests pass (`make test`)
- [x] Tested `kernel browsers create --output json` - no zero-value
fields
- [x] Tested `kernel browsers list --output json` - no zero-value fields
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Standardizes `--output json` to pretty-print the original API response
using SDK `RawJSON()` instead of re-marshaling Go structs.
>
> - Adds `pkg/util/json.go` with `PrintPrettyJSON` and
`PrintPrettyJSONSlice` helpers that indent raw SDK JSON
> - Refactors JSON output across commands (`app`, `deploy history`,
`browser-pools`, `browsers` incl. replays/process/fs, `extensions`,
`proxies`) to use the new helpers; consistent empty slice handling
> - Special-case `browsers view` to emit `{ "liveViewUrl": ... }` with
proper JSON escaping
> - Updates tests (`browsers_test.go`) to validate pretty JSON output
using populated `RawJSON()`
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
beccbd7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments