Repository navigation
fix(cron): keep valid command env vars when a sibling value is non-string (#105433) - #106100
Conversation
|
CI note: the single red check (
I've deliberately left the The cron env fix itself is fully green: |
|
Codex review: needs maintainer review before merge. Reviewed July 13, 2026, 3:16 AM ET / 07:16 UTC. Summary PR surface: Source +8, Tests +34. Total +42 across 2 files. Reproducibility: yes. The existing record helper's early Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the owner-local filtering fix after exact-head refresh and merge gating, preserving valid command environment strings while continuing to remove an entirely invalid map without changing the Gateway schema. Do we have a high-confidence way to reproduce the issue? Yes. The existing record helper's early Is this the best way to solve the issue? Yes. Filtering inside the owning record normalizer matches the adjacent string-array behavior and avoids adding special cases to cron callers or changing the Gateway contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b57e7b74e6f8. Label changesLabel justifications:
Evidence reviewedPR surface: Source +8, Tests +34. Total +42 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
d80bbd7 to
9c3ccc5
Compare
…ring (openclaw#105433) normalizeTrimmedStringRecord returned undefined whenever any env value was non-string, so payload normalization deleted the entire env map before gateway schema validation, silently dropping valid siblings (e.g. env {DEBUG:true, PATH:'/bin'} lost PATH). It now filters invalid entries and only normalizes the map away when no valid entries remain, matching the sibling normalizeTrimmedStringArray behavior in the same file.
9c3ccc5 to
0882fa5
Compare
|
ClawSweeper proof for current head Rebased onto latest Verification on the rebased head:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: MoerAI <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6493c400d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!key || typeof rawValue !== "string") { | ||
| throw new Error("command env must be an object with non-blank keys and string values"); |
There was a problem hiding this comment.
Preserve valid env entries in mixed maps
When a command payload has env: { PATH: "/bin", DEBUG: true }, this branch throws and the gateway catches it as INVALID_REQUEST, so the job is not created or updated and the valid PATH entry still never survives. The normalizer already canonicalizes inputs before CronPayloadSchema validation; for this mixed-env case, filter out malformed entries and keep the string-valued siblings instead of failing the whole request.
Useful? React with 👍 / 👎.
| if ("env" in next) { | ||
| const env = normalizeTrimmedStringRecord(next.env); | ||
| if (env !== undefined) { | ||
| next.env = env; | ||
| } else { | ||
| delete next.env; | ||
| } | ||
| next.env = normalizeCommandEnv(next.env); |
There was a problem hiding this comment.
Validate env only for command payloads
This runs before the kind-specific pruning later in coercePayload, so an otherwise valid agentTurn or systemEvent add/update that carries a stray non-object/non-string env now fails during normalization even though those branches delete env for non-command payloads. Guard this normalization on next.kind === "command" or move it into the command branch so irrelevant fields continue to be pruned.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
|
Final behavior note: the maintainer rewrite changed the fix shape before landing. A present malformed command |
…ring (openclaw#105433) (openclaw#106100) * fix(cron): keep valid command env vars when a sibling value is non-string (openclaw#105433) normalizeTrimmedStringRecord returned undefined whenever any env value was non-string, so payload normalization deleted the entire env map before gateway schema validation, silently dropping valid siblings (e.g. env {DEBUG:true, PATH:'/bin'} lost PATH). It now filters invalid entries and only normalizes the map away when no valid entries remain, matching the sibling normalizeTrimmedStringArray behavior in the same file. * fix(cron): reject malformed command env maps Co-authored-by: MoerAI <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
…ring (openclaw#105433) (openclaw#106100) * fix(cron): keep valid command env vars when a sibling value is non-string (openclaw#105433) normalizeTrimmedStringRecord returned undefined whenever any env value was non-string, so payload normalization deleted the entire env map before gateway schema validation, silently dropping valid siblings (e.g. env {DEBUG:true, PATH:'/bin'} lost PATH). It now filters invalid entries and only normalizes the map away when no valid entries remain, matching the sibling normalizeTrimmedStringArray behavior in the same file. * fix(cron): reject malformed command env maps Co-authored-by: MoerAI <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Fixes #105433
What Problem This Solves
A command cron job whose
envmap contained a single non-string value silently lost its entire environment. For example,env: { DEBUG: true, PATH: "/bin" }sent tocron.add/cron.updatewas normalized down to noenvat all — the validPATHstring was discarded alongside the invalidDEBUGboolean, before the Gateway ever validated the request. Operators got no error and no indication that their configured environment had vanished.Why This Change Was Made
Root cause:
normalizeTrimmedStringRecordinsrc/cron/normalize.tsreturnedundefinedas soon as any entry was non-string, and theenvbranch treatsundefinedas "delete the whole field". So one bad value discarded every valid sibling.The sibling helper in the same file,
normalizeTrimmedStringArray, already handles this correctly: it filters invalid entries and only collapses toundefinedwhen nothing valid remains. This change makes the record helper match that behavior — skip invalid entries, and only normalize the map away entirely when no valid entries survive.Owner boundary: the fix stays inside the record normalizer that owns this semantic, mirroring the array normalizer right next to it. No caller, schema, or Gateway-validation change.
Non-goals: it does not change how an all-invalid or absent
envis handled (still dropped/absent), and does not alter the Gateway request schema.User Impact
Valid cron command environment variables now survive when a sibling value is malformed, instead of the whole
envmap silently disappearing. Fully-validenvmaps are unchanged (byte-for-byte).Evidence
Real behavior on current head
d80bbd782a01, exercised through the actualnormalizeCronJobCreatepath with a command payloadenv: { DEBUG: true, PATH: "/bin" }:Before fix:
After fix:
vitest run src/cron/normalize.test.ts(cron config) — 62 passed, including 2 new#105433regression tests (keeps valid sibling; drops the block only when no valid entries remain).expected undefined to deeply equal { PATH: '/bin' }) — proving the test actually guards this bug.run-tsgo -p tsconfig.core.jsonand-p test/tsconfig/tsconfig.core.test.json— no errors.oxfmt --checkon both touched files — clean.AI-assisted (Claude Code); I have reviewed and understand every line.