Repository navigation
fix(channels): tombstone corrupt ingress rows - #105259
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b4405bd9e
ℹ️ 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".
| const record = baseRecord<TPayload, TMetadata>(row); | ||
| if (record) { | ||
| records.push(record); |
There was a problem hiding this comment.
Keep skipped corrupt rows recoverable
When a pending row has corrupt payload_json, this filters it out of listPending() without tombstoning it or surfacing its id. In the Telegram polling/webhook drains, candidateUpdateIds is built from listTelegramSpooledUpdates() and then passed to claimNext, so a corrupt pending row skipped here is never included in the candidate set that would tombstone it; after later valid rows drain, the candidate set is empty and the corrupt row stays pending until TTL, causing repeated scans and failing the intended scrub/tombstone behavior for the main spool path.
Useful? React with 👍 / 👎.
| @@ -34,6 +34,7 @@ Docs: https://docs.openclaw.ai | |||
| - **Gradium TTS credential egress:** reject non-HTTPS, foreign-host, and hostname-lookalike base URLs before dispatching API keys, and pin guarded transport to Gradium's documented API hostname. (#101280) Thanks @zhangguiping-xydt. | |||
| - **Gateway command SecretRefs:** preserve authoritative active-snapshot values when another command secret remains unresolved, falling back locally only for missing paths instead of emitting a per-turn `secrets.resolve` failure. (#96661) Thanks @SunnyShu0925. | |||
| - **Cron delivery status:** keep successful isolated agent turns at `status=ok` when downstream delivery fails, while preserving the send failure separately in delivery state and run logs. (#95419) Thanks @Alix-007. | |||
| - **Channel ingress recovery:** tombstone and scrub malformed durable ingress payloads without letting corrupt rows hide or starve later valid messages. (#98402) Thanks @Pick-cat. | |||
There was a problem hiding this comment.
Remove the hand-written changelog entry
This is a normal fix commit, but root AGENTS.md says CHANGELOG.md is release-only and “Do not edit for normal PRs, direct main fixes, or ship it; release generation owns it.” Keeping this manual Unreleased entry risks stale or duplicated release notes because the release generator derives changelog content from merged PRs and direct commits.
Useful? React with 👍 / 👎.
8b4405b to
e9117d7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9117d70e8
ℹ️ 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".
| return rows | ||
| .map((row) => claimedRecord<TPayload, TMetadata>(row)) | ||
| .filter((rec): rec is ChannelIngressQueueClaim<TPayload, TMetadata> => rec !== null); |
There was a problem hiding this comment.
Keep preserved corrupt claims blocking their lane
When shouldRecoverCorrupt declines to tombstone a corrupt claimed row (for example because extensions/telegram/src/polling-session.ts:954 sees a fresh live owner), this filter drops that still-claimed row from listClaims(). The Telegram polling and webhook drains build claimedLaneKeys only from listTelegramSpooledUpdateClaims() (polling-session.ts:960, webhook.ts:783), so the preserved corrupt claim's lane_key no longer blocks later pending updates in the same chat; a sibling process that claimed the original row before corruption may still be producing side effects, breaking the spool's per-lane ordering guarantee.
Useful? React with 👍 / 👎.
…tale recovery Two P1 gaps: enqueue() threw on duplicate when the existing row had corrupt payload_json, and recoverStaleClaims() silently skipped corrupt claimed rows, leaving them invisible to recovery. Both paths now tombstone the unrecoverable row as failed with reason "corrupt_payload" and return a proper result. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Co-Authored-By: Claude Opus 4.7 <[email protected]>
e9117d7 to
c255f3c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c255f3c2b3
ℹ️ 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".
| throw new Error(`Failed to tombstone corrupt ingress event ${queueName}/${eventId}`); | ||
| } | ||
| return { | ||
| kind: "failed", |
There was a problem hiding this comment.
Do not ack valid redeliveries as failed duplicates
When the existing row is a corrupt pending entry and the platform redelivers the same event with a valid payload, returning kind: "failed" here makes callers treat the enqueue as an idempotent duplicate even though no handler ever processed the event. For example, Telegram writeTelegramSpooledUpdate() ignores the enqueue result, so webhook returns 200 after line 955/963 and polling acks the worker at polling-session.ts:1321-1328; the row has been tombstoned as failed, no pending copy remains, and later redeliveries hit the failed tombstone as well. This should either preserve/reinsert the redelivered payload as pending or surface an error so the transport does not acknowledge the update.
Useful? React with 👍 / 👎.
|
Land-ready proof for exact head
Known proof gap: no synthetic multi-process fault injection beyond the token/cutoff race tests. The implementation remains compare-and-set guarded, and Telegram's live-process/lane ownership paths are covered by focused tests. |
|
Merged via squash.
|
* fix(infra): guard channel ingress queue parseJson against corrupted JSON * fix(infra): fix type assertion in ingress queue test * fix(infra): use tagged parse result and validate payload before claiming * fix(infra): remove unnecessary non-null assertion in ingress queue test * fix(infra): scan corrupt ingress rows in claimNext * test(gateway): avoid typed empty mock call tuple access * fix(infra): tombstone corrupt ingress rows on duplicate enqueue and stale recovery Two P1 gaps: enqueue() threw on duplicate when the existing row had corrupt payload_json, and recoverStaleClaims() silently skipped corrupt claimed rows, leaving them invisible to recovery. Both paths now tombstone the unrecoverable row as failed with reason "corrupt_payload" and return a proper result. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(infra): resolve lint shadow and await-thenable in recoverStaleClaims Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(channels): tombstone corrupt ingress rows * test(channels): use explicit placeholder claim tokens * refactor(channels): name claim token values * refactor(channels): keep claim projection direct * fix(channels): preserve active ingress claims * fix(channels): make corrupt recovery policy-aware * refactor(channels): name corrupt claim token * fix(channels): bound corrupt ingress reconciliation * fix(channels): paginate pending ingress by key * refactor(telegram): return live owner check directly * build(plugin-sdk): refresh public export budget --------- Co-authored-by: Pick-cat <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
* fix(infra): guard channel ingress queue parseJson against corrupted JSON * fix(infra): fix type assertion in ingress queue test * fix(infra): use tagged parse result and validate payload before claiming * fix(infra): remove unnecessary non-null assertion in ingress queue test * fix(infra): scan corrupt ingress rows in claimNext * test(gateway): avoid typed empty mock call tuple access * fix(infra): tombstone corrupt ingress rows on duplicate enqueue and stale recovery Two P1 gaps: enqueue() threw on duplicate when the existing row had corrupt payload_json, and recoverStaleClaims() silently skipped corrupt claimed rows, leaving them invisible to recovery. Both paths now tombstone the unrecoverable row as failed with reason "corrupt_payload" and return a proper result. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(infra): resolve lint shadow and await-thenable in recoverStaleClaims Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(channels): tombstone corrupt ingress rows * test(channels): use explicit placeholder claim tokens * refactor(channels): name claim token values * refactor(channels): keep claim projection direct * fix(channels): preserve active ingress claims * fix(channels): make corrupt recovery policy-aware * refactor(channels): name corrupt claim token * fix(channels): bound corrupt ingress reconciliation * fix(channels): paginate pending ingress by key * refactor(telegram): return live owner check directly * build(plugin-sdk): refresh public export budget --------- Co-authored-by: Pick-cat <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]> (cherry picked from commit a824078)
What Problem This Solves
Replaces #98402 on current main. A malformed durable channel-ingress payload could throw during JSON parsing, hide later valid rows behind list limits, and repeatedly starve
claimNextwithout making durable progress.Why This Change Was Made
The replacement centralizes a Kysely compare-and-set tombstone operation for corrupt pending and claimed rows. It scrubs payload, metadata, and claim fields; validates JSON before limited pending selection; makes
claimNextdurably advance past corrupt rows; and reuses the same guarded cleanup during stale-claim recovery. Recovery counts only rows actually changed, preventing an older worker from clearing a newer claim generation.This preserves @Pick-cat's contributor commits while removing the unrelated gateway test edit and consolidating the final repair at the ingress-queue owner boundary.
User Impact
One corrupt durable ingress row no longer blocks later valid channel messages. Corrupt data is retained only as a failed tombstone with a bounded reason, while valid queued work remains listable and claimable.
Evidence
tbx_01kxarzhjkg0ypn8ttfx5smybzandtbx_01kxat2vsnk60cwbghnym4j6py: 163 focused core queue, Telegram spool, polling, and webhook tests passed.tsgo:core,tsgo:test:src,tsgo:extensions, andtsgo:extensions:test.pnpm buildpassed, including the public Plugin SDK declaration graph check (5,057,529 / 5,100,000bytes).10,630public exports, including the three additive corrupt-claim re-exports.scanLimit: 1convergence, direct claim cleanup, pending duplicate cleanup, active-claim preservation, stale-claim compare-and-set races, and recovery-predicate ownership.shouldRecoverCorruptSDK contract is documented indocs/plugins/sdk-runtime.md.Supersedes #98402.