Skip to content

fix(cron): honor configured delivery.channel instead of misrouting (#46899) - #91162

Closed
sumitaich1998 wants to merge 1 commit into
openclaw:mainfrom
sumitaich1998:fix/issue-46899-cron-delivery-channel
Closed

sumitaich1998 wants to merge 1 commit into
openclaw:mainfrom
sumitaich1998:fix/issue-46899-cron-delivery-channel

Conversation

@sumitaich1998

Copy link
Copy Markdown

Summary

A cron job configured with an explicit delivery.channel (e.g. Telegram) could be silently misrouted to a different enabled channel (e.g. Feishu) using a stale/leftover recipient id, failing with Invalid ids: [-1002381931352]. This makes the configured delivery.channel authoritative again by preserving it through cron delivery normalization, so an explicit channel can no longer be overridden by implicit session routing.

Root cause

delivery.channel is canonically a string channel id (CronMessageChannel). Cron delivery normalization parses delivery fields in parseDeliveryInput (src/cron/delivery-field-schemas.ts), where channel was validated with the string-only LowercaseNonEmptyStringFieldSchema.

When a persisted/legacy cron job carries delivery.channel as a channel-reference object ({ id: "telegram" }) instead of a bare string, the schema rejects it and coerceDelivery (src/cron/normalize.ts) deletes the channel field. The job is then persisted/hydrated with no channel, so at run time resolveCronDeliveryPlan (src/cron/delivery-plan.ts) degrades to implicit "last" routing. With multiple channels enabled, "last" resolves to the session's last channel/recipient — e.g. Feishu with a stale leftover id -1002381931352 — instead of delivering via Telegram.

The fix

Recover the canonical channel id from a { id } channel reference during delivery normalization so the explicit channel survives instead of being dropped:

  • src/cron/delivery-field-schemas.ts: add DeliveryChannelFieldSchema, which preprocesses a { id: string } reference into its id before applying the existing lowercase/non-empty string validation, and use it for channel in parseDeliveryInput.

This keeps the runtime canonical (channel stays a string), normalizes the legacy/alternate shape at the ingress layer (consistent with the architecture rule that legacy shapes normalize before runtime), and preserves the legitimate "no channel configured → last" fallback: omitted/empty/null channels are untouched, and genuinely unrecoverable shapes (no string id) still drop as before.

Verification

  • Focused unit test (single worker, low CPU):
    OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/cron/normalize.test.ts → 49 passed.
    New regression test recovers an object-shaped delivery.channel so cron honors the explicit channel (#46899) fails before the fix (expected undefined to be 'telegram') and passes after. It asserts both that normalization preserves channel: "telegram" and that resolveCronDeliveryPlan(...).channel === "telegram" (never the "last" fallback that misroutes to Feishu).
  • Earlier combined run of the sibling cron suites also passed: src/cron/normalize.test.ts src/cron/delivery.test.ts src/cron/delivery-plan.test.ts → 69 passed.
  • Intentionally skipped to limit local CPU/heat: tsgo typecheck, pnpm build, and the full suite/broad lint. The change is small and confined to cron delivery normalization (only parseDeliveryInput's channel field consumes the new schema).
  • OpenClaw was NOT run locally (no gateway/CLI/openclaw). Verification is static review plus focused unit tests only; live cron delivery (Telegram/Feishu) was not exercised.

Fixes #46899

@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 30, 2026, 3:46 PM ET / 19:46 UTC.

Summary
The PR changes cron delivery normalization to recover a string channel id from object-shaped delivery.channel values and adds a regression test for explicit Telegram routing.

PR surface: Source +14, Tests +20. Total +34 across 2 files.

Reproducibility: yes. for the source-level path: current main parses delivery.channel with a string-only schema, deletes invalid object-shaped values during normalization, and delivery planning can then fall back to last. I did not establish a live Telegram/Feishu reproduction from the reporter's exact stored job row.

Review metrics: 1 noteworthy metric.

  • Cron delivery normalization: 1 field changed. delivery.channel parsing controls persisted cron routing and scheduled message delivery when multiple channels are configured.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #46899
Summary: This PR is the active fix candidate for the canonical object-shaped or lost cron delivery.channel report; older similar work was closed unmerged and the wrong-account issue remains adjacent.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the branch against current main so the exact merge result can be reviewed.
  • [P1] Add redacted real behavior proof from a multi-channel cron setup, with private details such as tokens, phone numbers, IPs, and non-public endpoints removed.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body only lists focused unit tests and explicitly says OpenClaw and live Telegram/Feishu delivery were not exercised; add redacted terminal, log, screenshot, recording, or linked artifact proof from a real multi-channel cron run, then update the PR body or ask a maintainer for @clawsweeper re-review.

Mantis proof suggestion
A live Telegram transcript would materially prove the scheduled output reaches the configured Telegram channel when another channel is enabled. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live proof: verify a cron job with delivery.channel=telegram and another channel enabled delivers scheduled output to Telegram, not the other channel.

Risk before merge

  • [P1] Live GitHub reports the PR as conflicting, so maintainers cannot review or merge the exact current-main three-way result yet.
  • [P1] The PR body reports focused unit tests only and explicitly says no OpenClaw gateway or live Telegram/Feishu cron delivery was exercised.
  • [P1] Because this changes persisted cron delivery normalization, maintainers still need upgrade-style proof that object-shaped input is repaired before scheduled delivery when multiple channels are enabled.

Maintainer options:

  1. Require branch refresh and live proof (recommended)
    Ask for a current-main refresh plus redacted terminal, log, screenshot, recording, or linked artifact proof that a Telegram-configured cron job delivers through Telegram with another channel enabled.
  2. Accept unit-only evidence deliberately
    Maintainers could resolve the conflict and land with focused unit coverage only, but that accepts remaining live transport and upgrade-path uncertainty.
  3. Pause and replace if needed
    If the contributor cannot refresh the branch or provide proof, keep the linked issue open and replace this with a maintainer-proven narrow fix later.

Next step before merge

  • [P1] Contributor or maintainer action is required because the branch is conflicting and real environment proof is missing; automation cannot prove the contributor's Telegram/Feishu setup for them.

Security
Cleared: The diff only changes cron normalization and a colocated test; it does not touch dependencies, CI, package resolution, secrets, permissions, or code-execution surfaces.

Review details

Best possible solution:

Rebase the parser-boundary fix onto current main, keep runtime delivery.channel canonical as a string, and merge only after redacted multi-channel cron proof shows Telegram-configured jobs deliver to Telegram.

Do we have a high-confidence way to reproduce the issue?

Yes for the source-level path: current main parses delivery.channel with a string-only schema, deletes invalid object-shaped values during normalization, and delivery planning can then fall back to last. I did not establish a live Telegram/Feishu reproduction from the reporter's exact stored job row.

Is this the best way to solve the issue?

Yes for fix shape, but not for merge readiness: parser-boundary recovery is the narrow maintainable solution while keeping runtime delivery.channel canonical as a string. The branch still needs a current-main refresh and real multi-channel delivery proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 076da567f434.

Label changes

Label justifications:

  • P1: The PR targets a linked scheduled message-delivery regression where cron output can route to the wrong enabled channel.
  • merge-risk: 🚨 compatibility: The diff changes normalization of persisted or alternate-shaped cron delivery config during cron job ingestion.
  • merge-risk: 🚨 message-delivery: The changed field directly controls which channel receives scheduled cron output when multiple channels are configured.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body only lists focused unit tests and explicitly says OpenClaw and live Telegram/Feishu delivery were not exercised; add redacted terminal, log, screenshot, recording, or linked artifact proof from a real multi-channel cron run, then update the PR body or ask a maintainer for @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR affects visible Telegram cron delivery and can be demonstrated in a short live Telegram proof.
Evidence reviewed

PR surface:

Source +14, Tests +20. Total +34 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 15 1 +14
Tests 1 20 0 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 1 +34

What I checked:

  • Root policy read and applied: Root AGENTS.md was read fully; its read-beyond-diff, compatibility-sensitive routing/config, and Telegram real-proof guidance affected this review. (AGENTS.md:17, 076da567f434)
  • Live PR state: Live GitHub reports head 336ca03c1bf0e8938a5c68dea072db861d4c5618 as mergeable=CONFLICTING and mergeStateStatus=DIRTY, with maintainerCanModify=true. (336ca03c1bf0)
  • Current main parser still drops object channel refs: Current main parses delivery.channel with LowercaseNonEmptyStringFieldSchema, so an object-shaped value such as { id: "telegram" } is not recovered before validation. (src/cron/delivery-field-schemas.ts:48, 076da567f434)
  • Normalization deletes rejected channel values: coerceDelivery deletes channel when parsing returns no channel value, except for explicit null clears, so a rejected object-shaped channel can disappear before runtime planning. (src/cron/normalize.ts:328, 076da567f434)
  • Planner fallback can misroute after channel loss: Without a normalized delivery channel, resolveCronDeliveryPlan resolves announce delivery through resolveAnnounceChannel, which can fall back to last. (src/cron/delivery-plan.ts:91, 076da567f434)
  • Persisted jobs use the same normalization path: SQLite/config cron rows call normalizeCronJobInput before becoming runtime CronJob records, so this parser behavior affects persisted or imported jobs. (src/cron/store/row-codec.ts:151, 076da567f434)

Likely related people:

  • steipete: Feature history shows parser-boundary consolidation and legacy delivery migration work on the central cron normalization path. (role: recent area contributor; confidence: high; commits: 86b519850e33, 802bdb099e0f; files: src/cron/delivery-field-schemas.ts, src/cron/normalize.ts, src/commands/doctor/cron/legacy-delivery.ts)
  • shakkernerd: History shows the cron delivery planning/sending split in the path that owns fallback from normalized channel to runtime delivery plan. (role: adjacent owner; confidence: medium; commits: de952c036abc; files: src/cron/delivery-plan.ts, src/cron/delivery.ts)
  • tyler6204: Earlier cron announce routing work touched the surrounding delivery behavior used by this path. (role: feature history contributor; confidence: medium; commits: 75001a049007; files: src/cron/normalize.ts, src/cron/delivery.ts, src/cron/service/ops.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-06-21T18:57:34.276Z sha 336ca03 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 7, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed stale Marked as stale due to inactivity labels Jul 21, 2026
@clawsweeper

clawsweeper Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(cron): honor configured delivery.channel instead of misrouting (#46899) This is item 1/1 in the current shard. Shard 17/22.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict stalled_unproven_pr (decision packet 2026-07-22T05:58:51.752Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026

This branch had an error being deployed

1 failed deployment
qa-live-shared — 336ca03c Deployed Jun 7, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #136958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cron Job Delivery Channel Mismatch - Telegram Configured but Feishu Used

2 participants