fix(discord): keep components schema optional in message tool#54800
fix(discord): keep components schema optional in message tool#54800artwalker wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes a schema validation bug where Discord Confidence Score: 5/5Safe to merge — minimal, targeted schema fix with no runtime logic changes and a new regression test covering the corrected behavior. The fix is a one-line structural change per file that follows an already-established and tested pattern (createMessageToolButtonsSchema). The new test directly validates the invariant that components is not required, the mock was updated to match the real signature, and no rendering logic or dispatch paths were touched. No other call sites remain with the same double-wrap pattern. No files require special attention.
|
| Filename | Overview |
|---|---|
| extensions/discord/src/message-tool-schema.ts | Wraps return value of createDiscordMessageToolComponentsSchema() in Type.Optional(), fixing the root cause of the required-field bug. |
| extensions/discord/src/channel-actions.ts | Removes now-redundant outer Type.Optional() wrapper at the components call site. |
| extensions/mattermost/src/channel.ts | Removes now-redundant outer Type.Optional() wrapper from the buttons call site, since createMessageToolButtonsSchema() already returns Type.Optional() internally. |
| src/agents/tools/message-tool.test.ts | Updates local mock to return Type.Optional(...) matching the real function, and adds a regression test asserting components is absent from the required array. |
Reviews (1): Last reviewed commit: "fix(discord): keep components schema opt..." | Re-trigger Greptile
The `components` property contributed by the Discord channel plugin
was incorrectly treated as required in the merged message tool schema,
causing validation failures on plain file attachment sends:
Validation failed for tool "message":
- components: must have required property 'components'
Root cause: `createDiscordMessageToolComponentsSchema()` returned a
bare `Type.Object(...)`. Although the call site in channel-actions.ts
wrapped it with `Type.Optional()`, the optional marker was lost during
schema property merging into the final `Type.Object()` — the same
issue fixed for `buttons` in openclaw#54418.
Fix: Move `Type.Optional()` into the factory function itself (matching
the pattern of `createMessageToolButtonsSchema()` and
`createMessageToolCardSchema()`), and remove the now-redundant outer
wrapper at the call site.
Also fixes the same double-wrap on Mattermost's `buttons` call site
that was missed in openclaw#54418.
Fixes openclaw#54763
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
78bfae8 to
cf77487
Compare
|
Closing because the message-tool surface this PR patched has since been refactored on main. Discord no longer exposes the old inline components schema from |
Summary
componentsproperty is incorrectly required in the message tool schema, causing validation failures on plain file attachment sends (must have required property 'components').components: {}workaround.Type.Optional()intocreateDiscordMessageToolComponentsSchema()factory function (matchingcreateMessageToolButtonsSchema()pattern from fix: make buttons schema optional in message tool #54418). Also fixed identical double-wrap on Mattermost'sbuttonscall site missed in fix: make buttons schema optional in message tool #54418.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
buttons)Root Cause / Regression History (if applicable)
createDiscordMessageToolComponentsSchema()returnsType.Object(...)withoutType.Optional(). The call site wraps withType.Optional(), but this marker is lost when properties are merged into the finalType.Object()viamergeToolSchemaProperties+buildMessageToolSchemaFromActions.componentsoptionality in the merged message tool schema.buttonsby movingType.Optional()intocreateMessageToolButtonsSchema(). The Discordcomponentsand Mattermostbuttonscall sites were not updated.Regression Test Plan (if applicable)
src/agents/tools/message-tool.test.ts,extensions/discord/src/channel-actions.test.tscomponentsmust NOT appear inrequiredarray of merged message tool schema.User-visible / Behavior Changes
components: {}workaround.Security Impact (required)
NoNoNoNoNoRepro + Verification
Steps
message(action: "send", media: "/path/to/file.pdf")must have required property 'components'. After fix: sends successfully.Evidence
Human Verification (required)
componentsnot inrequiredarray, test mock updated to match real signature, Mattermost double-wrap fixedReview Conversations
Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
Risks and Mitigations
🤖 This PR was AI-assisted (Claude Code). All changes were reviewed, tested, and verified by the author.