[codex] add platform flag for images and runs#54
Conversation
ec08ca3 to
f1a9bea
Compare
f1a9bea to
4a26c20
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Platform flag ignored on create
- I appended imageCreateRequestOptions in handleImageCreateLike so hypeman image create now forwards --platform to Images.New requests.
Or push these changes by commenting:
@cursor push 30a6463dd8
Preview (30a6463dd8)
diff --git a/pkg/cmd/imagecmd.go b/pkg/cmd/imagecmd.go
--- a/pkg/cmd/imagecmd.go
+++ b/pkg/cmd/imagecmd.go
@@ -166,6 +166,7 @@
if cmd.Root().Bool("debug") {
opts = append(opts, debugMiddlewareOption)
}
+ opts = append(opts, imageCreateRequestOptions(cmd)...)
format := cmd.Root().String("format")
transform := cmd.Root().String("transform")You can send follow-ups to the cloud agent here.
|
Created a monitoring plan for this PR. What this PR does: Adds a Intended effect:
Risks:
Status updates will be posted automatically on this PR as monitoring progresses. |
The server now returns a platform field on instance and image responses, but the SDK v0.20.0 structs predate it. Render `hypeman inspect` from the raw server payload (instance.RawJSON()) so the platform shows, and add a PLATFORM column to `image list` via a shared platformFromRaw helper. Long-term this is better fixed by an SDK regen/bump. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hot restore precondition - During a cold `run` the image-resolve poll loop now treats a transient 404 as still-pulling and keeps waiting (via errors.As), instead of surfacing a misleading not-found. - Document on `snapshot restore --help` that the target must not be Running (returns 409 invalid_state). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n helper Reviewer-cleanup pass: - Fix: `hypeman image create --platform` was silently dropped — handleImageCreateLike never forwarded the platform option. It now does. (Cursor Bugbot: "Platform flag ignored on create".) - Remove the misplaced platform-option append on `image list` (no --platform flag there, so it was always a no-op). - Collapse the three identical platform request-option helpers (imageCreateRequestOptions / imageCreateOptionsForPlatform / instanceCreateOptionsForPlatform) into one platformRequestOptions(platform). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Colon in env keys breaks redaction
- Updated
escapeSJSONKeyto escape:and extended redaction tests to cover colon-containing env keys so redaction no longer falls back to unmodified JSON.
- Updated
Or push these changes by commenting:
@cursor push e7c5384733
Preview (e7c5384733)
diff --git a/pkg/cmd/inspect.go b/pkg/cmd/inspect.go
--- a/pkg/cmd/inspect.go
+++ b/pkg/cmd/inspect.go
@@ -95,10 +95,10 @@
}
// escapeSJSONKey escapes characters sjson treats specially in a path (the '.'
-// separator plus the '*', '?', '|', '#', and '@' wildcards/modifiers) so env var
-// names containing them address the intended key.
+// and ':' separators plus the '*', '?', '|', '#', and '@' wildcards/modifiers)
+// so env var names containing them address the intended key.
func escapeSJSONKey(key string) string {
- for _, special := range []string{".", "*", "?", "|", "#", "@"} {
+ for _, special := range []string{".", ":", "*", "?", "|", "#", "@"} {
key = strings.ReplaceAll(key, special, "\\"+special)
}
return key
diff --git a/pkg/cmd/inspect_test.go b/pkg/cmd/inspect_test.go
--- a/pkg/cmd/inspect_test.go
+++ b/pkg/cmd/inspect_test.go
@@ -35,12 +35,12 @@
})
t.Run("handles env keys containing sjson special chars", func(t *testing.T) {
- // '*', '?', '|', '#', '@' are all special to sjson path parsing.
- raw := `{"env":{"A*B":"s1","C?D":"s2","E|F":"s3","G#H":"s4","I@J":"s5"}}`
+ // ':', '*', '?', '|', '#', '@' are all special to sjson path parsing.
+ raw := `{"env":{"A:B":"s0","A*B":"s1","C?D":"s2","E|F":"s3","G#H":"s4","I@J":"s5"}}`
redacted := redactEnvValues(raw)
- for _, key := range []string{`env.A\*B`, `env.C\?D`, `env.E\|F`, `env.G\#H`, `env.I\@J`} {
+ for _, key := range []string{`env.A\:B`, `env.A\*B`, `env.C\?D`, `env.E\|F`, `env.G\#H`, `env.I\@J`} {
assert.Equal(t, "[hidden]", gjson.Get(redacted, key).String(), "key %s", key)
}
})You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit de21b5d. Configure here.
| for _, special := range []string{".", "*", "?", "|", "#", "@"} { | ||
| key = strings.ReplaceAll(key, special, "\\"+special) | ||
| } | ||
| return key |
There was a problem hiding this comment.
Colon in env keys breaks redaction
Medium Severity
escapeSJSONKey does not escape : in env var names, but sjson path syntax treats colons specially. Keys containing : can make sjson.Set fail or target the wrong path; redactEnvValues then returns the original JSON, exposing secret env values on default inspect without --show-env.
Reviewed by Cursor Bugbot for commit de21b5d. Configure here.
Addressed Cursor Bugbot finding + cleanupBugbot "Platform flag ignored on create" — fixed in Also unified the three identical platform request-option helpers (
|



What this does
Adds a Docker-style
--platformflag to the Hypeman CLI so local (Apple-Silicon) users can drive the Rosetta / multi-platform support from hypeman #279 directly:Pairs with server PR kernel/hypeman#279 (merge/deploy that first — the server does the actual platform resolution + validation).
Changes
--platformonhypeman pull,hypeman image create, andhypeman run(os/arch[/variant]). Threaded through auto-pull duringrunand onto the final instance-create call.hypeman inspectnow renders the server's raw response (RawJSON()) instead of marshaling the typed SDK struct, so newly-added fields likeplatformaren't dropped. Env values are still redacted (now viasjsonon the raw JSON).hypeman image listgains aPLATFORMcolumn.runcold-pull UX: a transient404while an image is still being pulled is treated as "still pulling" (viaerrors.As) instead of a misleading not-found.snapshot restore --helpdocuments the not-Running precondition.Reviewer notes
option.WithJSONSet("platform", …)calls and theRawJSON()rendering are deliberate temporary workarounds: the pinnedhypeman-goSDK (v0.20.0) predates theplatformfield, so it isn't typed yet. Both should be replaced with typed fields after an SDK regen/bump — they're commented as such. This is the main thing to be aware of while readingrun.go/inspect.go/imagecmd.go.run.go(flag + auto-pull threading) →imagecmd.go/pull.go(shared flag + list column) →inspect.go(RawJSON + env redaction) → tests.Validation
go test ./pkg/cmd ./cmd/hypeman go build -o bin/hypeman ./cmd/hypemanCI
lint+scangreen. Exercised end-to-end against a local server across the #279 QA rounds (pull/run/inspect/list at both arches, cold-pull, error paths).Note
Medium Risk
Changes instance/image API request shaping and inspect output path (raw JSON + env redaction); behavior depends on server platform support and temporary WithJSONSet workarounds until an SDK bump.
Overview
Adds Docker-style
--platform(os/arch[/variant]) onpull,image create, andrun, threading it through image pulls (including auto-pull inrun) and instance create viaoption.WithJSONSet("platform", …)until the pinned SDK exposes a typed field.image listshows a PLATFORM column read from each image’sRawJSON()(with-when missing).inspectoutputs the serverRawJSON()instead of marshaling the SDK struct so fields likeplatformare not dropped; env values are still redacted to[hidden]on the raw payload usingsjson, with path escaping for odd env key names.runtreats transient 404s while polling an in-flight cold pull as “still pulling” (isNotFoundErrornow useserrors.As).snapshot restore --helpnotes the instance must not be Running.Reviewed by Cursor Bugbot for commit de21b5d. Bugbot is set up for automated code reviews on this repo. Configure here.