fix(message): strip auto-populated poll and components params on send#708
Open
BingqingLyu wants to merge 5 commits into
Open
fix(message): strip auto-populated poll and components params on send#708BingqingLyu wants to merge 5 commits into
BingqingLyu wants to merge 5 commits into
Conversation
Models (especially GPT-family) tend to auto-fill optional poll and components fields from the shared message tool schema even when the user only wants a plain send with text/attachments. This causes two distinct failures: 1. Poll guard false positive: `hasPollCreationParams()` triggers on default values like `pollDurationHours: 0` (Number.isFinite(0) is true), rejecting valid send requests with "Poll fields require action poll". 2. Empty components skeleton: auto-populated `components.modal` with empty `fields: []` causes Discord rendering issues (broken attachment display, red X buttons) and validation errors. Fix: - `hasPollCreationParams()` now gates on `pollQuestion` only — without a question there is no actionable poll intent. - New `stripPollCreationParams()` removes all poll params (camelCase and snake_case) from send requests before the guard check. - New `stripEmptyComponents()` removes empty/skeleton components objects (no blocks, no text, empty modal) after parsing. Fixes openclaw#42820 Fixes openclaw#43015
Addresses review feedback: move stripEmptyComponents() call after action binding and scope it to send-only, so modal/broadcast/edit actions are not affected by the cleanup.
The guard can never fire after stripPollCreationParams removes all poll params. Remove the unreachable throw and unused hasPollCreationParams import. Addresses Greptile review feedback.
…ents - Skip stripping for array-based components (Discord TopLevelComponents[]) - Preserve container-only payloads (accentColor, reusable, spoiler) - Only strip truly empty skeleton objects with no meaningful content Addresses Codex P1 review feedback.
Keep the corrective error when pollQuestion is explicitly provided with action=send — the caller likely meant action=poll. Only strip noise params (pollDurationHours, pollMulti, etc.) that models auto-fill from the shared schema without poll intent. Addresses Codex P2 review feedback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
action="send"requests before the poll guard checkhasPollCreationParams()to only gate onpollQuestionpresence (the only field that unambiguously signals poll intent)componentsobjects that models auto-populate from the shared tool schemaProblem
Models (especially GPT-family) auto-fill optional poll and components fields from the message tool schema even when the user only wants a plain send. This causes:
Poll guard false positive:
hasPollCreationParams()returns true on default values likepollDurationHours: 0(Number.isFinite(0)is true), rejecting valid send+attachment requests withPoll fields require action "poll".Empty components skeleton: auto-populated
components.modalwith emptyfields: []causes Discord rendering issues (broken attachment display, red X buttons) and validation errors.Changes
src/poll-params.tshasPollCreationParams()now only checkspollQuestion; addedstripPollCreationParams()src/infra/outbound/message-action-runner.tsaction="send"before guard; callstripEmptyComponents()after parsingsrc/infra/outbound/message-action-params.tsstripEmptyComponents()to remove empty modal/blocks/textsrc/poll-params.test.tssrc/infra/outbound/message-action-runner.context.test.tsTest plan
src/poll-params.test.ts— 10 tests passedsrc/infra/outbound/message-action-runner.poll.test.ts— 6 tests passedsrc/infra/outbound/message-action-runner.context.test.ts— all passedFixes openclaw#42820
Fixes openclaw#43015