Skip to content

feat(slack): add channel file upload tool#165

Merged
peteski22 merged 3 commits into
mainfrom
feature/slack-send-channel-message-with-file
Jul 6, 2026
Merged

feat(slack): add channel file upload tool#165
peteski22 merged 3 commits into
mainfrom
feature/slack-send-channel-message-with-file

Conversation

@peteski22

@peteski22 peteski22 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

  • add slack_send_channel_message_with_file using Slack files_upload_v2 so file plus optional comment post together
  • add SendChannelMessageWithFileParams and SendChannelMessageWithFileResult models
  • add SlackScope.FILES_WRITE and scope mapping for the new tool (chat:write, files:write)
  • add tests for bytes input + comment, URL input resolution, upload failure mapping, and tool/type metadata

Why

Implements #153 by providing a first-class Slack channel file upload tool that composes with FileInput producers and uses the current v2 upload flow.

Validation

  • uv run pytest tests/providers/slack/test_tools.py tests/providers/slack/test_types.py tests/test_registry.py
  • uv run pre-commit run --all-files

Closes #153

Summary by CodeRabbit

  • New Features

    • Added a new Slack option to send a channel message with an attached file and optional comment.
    • File uploads now support both direct file data and files fetched from a URL.
    • Successful uploads now return the uploaded file details for easier confirmation.
  • Bug Fixes

    • Improved error handling for Slack upload failures with clearer, user-friendly messages.
    • Updated required access guidance so missing permissions now points to the correct Slack scopes.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@peteski22, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7c5962df-fa14-4804-9c22-8ce5404a7b75

📥 Commits

Reviewing files that changed from the base of the PR and between 795299d and 7217079.

📒 Files selected for processing (1)
  • tests/providers/slack/test_tools.py

Walkthrough

Adds a new Slack tool, slack_send_channel_message_with_file, that uploads a file to a channel via files_upload_v2, optionally with a comment. Introduces a FILES_WRITE scope, new Pydantic request/response types, error handling for HTTP/Slack API failures, and corresponding test coverage.

Changes

Slack channel file upload tool

Layer / File(s) Summary
FILES_WRITE scope and mapping
src/apron_tools/providers/slack/scopes.py
Adds SlackScope.FILES_WRITE (files:write) and maps slack_send_channel_message_with_file to [CHAT_WRITE, FILES_WRITE] in SCOPES.
Request/response models
src/apron_tools/providers/slack/types.py
Adds SendChannelMessageWithFileParams (channel_id, file: FileInput, comment) and SendChannelMessageWithFileResult (channel, file_id, file_permalink) with a custom __str__.
Tool implementation
src/apron_tools/providers/slack/tools.py
Adds slack_send_channel_message_with_file, resolving the file via resolve_file_input, calling files_upload_v2, handling httpx and Slack API errors, and extracting file metadata from the response.
Tests
tests/providers/slack/test_tools.py, tests/providers/slack/test_types.py
Adds tests for params/result models and tool behaviour, including bytes/URL uploads, error formatting, and scope assertions.

Related issues: Closes #153 (Add slack_send_channel_message_with_file post a file to a channel via files_upload_v2).

Suggested labels: review_needed_junior_swe, review_depth_deep

Suggested reviewers: (none specified)

🐰 A file hops into Slack with glee,
Comment tucked in, uploaded free,
files_upload_v2 takes the flight,
Scopes aligned, permissions right,
A rabbit's PR, tested thoroughly!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the new Slack channel file upload tool and matches the main change.
Linked Issues check ✅ Passed The tool, scopes, models, and tests match issue #153's requirements for v2 upload, FileInput, and error handling.
Out of Scope Changes check ✅ Passed The changes stay within the Slack file-upload feature and its tests; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/slack-send-channel-message-with-file

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/providers/slack/test_tools.py`:
- Around line 441-548: Add test coverage for the `resolve_file_input` error
branches in `TestSlackSendChannelMessageWithFile`: mock
`apron_tools.providers.slack.tools.resolve_file_input` to raise
`httpx.HTTPStatusError` and `httpx.HTTPError`, then assert
`slack_send_channel_message_with_file` returns a domain error instead of
propagating the exception. Reuse the existing
`test_file_from_url_is_resolved_before_upload` setup and the
`slack_send_channel_message_with_file` / `resolve_file_input` symbols to keep
the new cases close to the current URL-resolution test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dae7ee3e-0291-46af-9b59-bf155e97733b

📥 Commits

Reviewing files that changed from the base of the PR and between 45dcfe7 and 795299d.

📒 Files selected for processing (5)
  • src/apron_tools/providers/slack/scopes.py
  • src/apron_tools/providers/slack/tools.py
  • src/apron_tools/providers/slack/types.py
  • tests/providers/slack/test_tools.py
  • tests/providers/slack/test_types.py

Comment thread tests/providers/slack/test_tools.py
@peteski22 peteski22 merged commit 751c88c into main Jul 6, 2026
8 checks passed
@peteski22 peteski22 deleted the feature/slack-send-channel-message-with-file branch July 6, 2026 14:03
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.

Add slack_send_channel_message_with_file (post a file to a channel via files_upload_v2)

1 participant