Skip to content

Fix text/markdown_text mutual exclusion in chat methods#588

Merged
dblock merged 3 commits into
slack-ruby:masterfrom
dblock:fix-markdown-text-mutual-exclusion
Jul 5, 2026
Merged

Fix text/markdown_text mutual exclusion in chat methods#588
dblock merged 3 commits into
slack-ruby:masterfrom
dblock:fix-markdown-text-mutual-exclusion

Conversation

@dblock

@dblock dblock commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Problem

The submodule patch (b1be09b0) added markdown_text to the chat method arg_groups with a second group marked mutually_exclusive: true — meaning "use either but not both" (at-most-one). However the code generation template treated all mutually_exclusive: true groups as "exactly one required" (XOR), so calls like chat_update(attachments: ..., channel: ..., ts: ...) raised:

ArgumentError: Exactly one of :text, :markdown_text is required

This broke rspec ./spec/slack/web/api/endpoints/chat_spec.rb:302 (and the equivalent tests for postMessage, postEphemeral, scheduleMessage).

Fix (commit 1)

  • Add "required": false to the [text, markdown_text] arg_group in the 4 chat method JSON files in slack-api-ref to distinguish "at most one" from "exactly one required".
  • Update method.erb: when mutually_exclusive: true && required: false, emit a "mutually exclusive" guard instead of XOR. Existing views.open-style "exactly one" behaviour is preserved.
  • Update method_spec.erb: generate 'does not allow both X and Y' tests for at-most-one groups; skip raise expectations for combinations that violate at-most-one constraints in the broader at-least-one test.
  • Update spec/slack/web/api/endpoints/custom/chat_spec.rb error patterns to include :markdown_text.

Regeneration (commit 2)

Full regeneration of endpoints, specs, and commands from the updated templates and JSON, bringing in all other pending API changes from slack-api-ref@38cb2f40.

The arg_groups patch introduced a `mutually_exclusive: true` group for
[text, markdown_text] meaning "use either but not both" (at-most-one).
However the template treated all `mutually_exclusive: true` groups as
"exactly one required" (XOR), raising an error when only attachments
or blocks were provided.

- Add `"required": false` to the [text, markdown_text] arg_groups in
  the 4 chat method JSON files to mark them as at-most-one instead of
  exactly-one.
- Update method.erb to emit a "mutually exclusive" guard (at-most-one)
  vs the existing "Exactly one of" (XOR) based on required: false.
- Update method_spec.erb to generate "does not allow both" tests for
  at-most-one groups and skip raise expectations for single-arg combos
  that would violate those groups in the broader at-least-one test.
- Update custom chat_spec.rb error message patterns to include
  :markdown_text, which was added to the at-least-one group.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock dblock force-pushed the fix-markdown-text-mutual-exclusion branch from 998b24a to 9496e5d Compare July 5, 2026 15:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock dblock force-pushed the fix-markdown-text-mutual-exclusion branch from 9496e5d to f8b12a5 Compare July 5, 2026 15:30
@coveralls

coveralls commented Jul 5, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28745839451

Coverage increased (+0.07%) to 91.075%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 14 uncovered changes across 5 files (275 of 289 lines covered, 95.16%).
  • 6 coverage regressions across 4 files.

Uncovered Changes

File Changed Covered %
lib/slack/web/api/endpoints/admin_analytics_messages.rb 19 9 47.37%
lib/slack/web/api/endpoints/admin_conversations.rb 4 3 75.0%
lib/slack/web/api/endpoints/apps_icon.rb 8 7 87.5%
lib/slack/web/api/endpoints/apps_user_connection.rb 9 8 88.89%
lib/slack/web/api/endpoints/oauth_v2_user.rb 7 6 85.71%
Total (28 files) 289 275 95.16%

Coverage Regressions

6 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
lib/slack/web/api/endpoints/bookmarks.rb 3 73.33%
lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb 1 81.82%
lib/slack/web/api/endpoints/assistant_threads.rb 1 84.21%
lib/slack/web/api/endpoints/admin_functions_permissions.rb 1 81.82%

Coverage Stats

Coverage Status
Relevant Lines: 5759
Covered Lines: 5245
Line Coverage: 91.07%
Coverage Strength: 110.66 hits per line

💛 - Coveralls

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock dblock merged commit 1ff45ee into slack-ruby:master Jul 5, 2026
21 checks passed
@dblock dblock deleted the fix-markdown-text-mutual-exclusion branch July 5, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants