profile download: extract zstd tar to directory + handle 202#153
profile download: extract zstd tar to directory + handle 202#153
Conversation
The download endpoint now returns a zstd-compressed tar of the full user-data directory, plus 202 when the profile has not yet captured state. Update the CLI subcommand to require --to <dir>, stream the archive into that directory, and surface the 202 case as a friendly info message instead of writing an empty/invalid file. Also bump kernel-go-sdk to v0.52.0 and add klauspost/compress for zstd decoding. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR modifies the CLI subcommand and SDK client behavior for profile download, but does not change the kernel API endpoints themselves (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal). To monitor this PR anyway, reply with |
masnwilliams
left a comment
There was a problem hiding this comment.
Built and tested e2e against the API.
make testpasses- empty profile → 202 path: info message, exit 0, no dir created
- populated profile → ~4MB extracted with
Default/,Local State,Cookies/, etc. - relative
--to→ works - missing
--to→ clean required-flag error --topointing at file →not a directoryerror- unknown profile → 404 surfaced
Code looks good — path-traversal guard, perms stripped, symlinks deliberately skipped, 202/non-200 handled before extract.
Summary
The profile download endpoint now returns a zstd-compressed tar of the full Chrome user-data directory, and returns
202 Acceptedwhen a profile has not yet captured any state. This rewires the CLI subcommand to match.kernel profile download <id-or-name> --to <dir>—--tois now required and must point at a directory (created if missing). The archive is streamed and extracted into it.Profile '...' has no saved data yet. Use it in a browser session first to capture state.) and exit 0 — no zero-byte file or partial directory is written.--prettyand the JSON-pretty-print path: the body is no longer JSON.Bumps
github.com/kernel/kernel-go-sdktov0.52.0(which carries the newReturns a zstd-compressed tar file...doc comment onProfileService.Download) and addsgithub.com/klauspost/compressfor zstd decoding.No backwards compatibility shim — the old
--to <file>/--prettybehavior is gone.Test plan
make test(go vet + go test ./...)Default/,Local State,Cookies, etc. (~6 MB unpacked).Note
Medium Risk
Changes core CLI download behavior (breaking flag/semantics) and introduces archive extraction to disk, so bugs could lead to incorrect writes or incomplete restores despite added path-traversal guards and tests.
Overview
kernel profile downloadis rewired to require--to <dir>and stream-extract a zstd-compressed tar archive into that directory (replacing the prior “save response to file / pretty-print JSON” behavior).The command now treats
202 Acceptedas a non-error “no saved data yet” message, adds explicit handling for unexpected HTTP statuses, and validates tar entry paths to prevent path traversal while skipping non-file/dir entries.Dependencies are updated to
github.com/kernel/kernel-go-sdk v0.52.0andgithub.com/klauspost/compressfor zstd decoding; tests are updated to cover extraction, 202 behavior, and traversal rejection.Reviewed by Cursor Bugbot for commit 307f5c0. Bugbot is set up for automated code reviews on this repo. Configure here.