Skip to content

refactor(adapters/slack): move Web API calls onto typed slackapi methods - #133

Merged
ThomasK33 merged 4 commits into
mainfrom
refactor/slack-typed-slackapi
Oct 29, 2026
Merged

ThomasK33 merged 4 commits into
mainfrom
refactor/slack-typed-slackapi

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Why

Every open follow-up issue in coder/chat gets one small, reviewed PR, and this one moves the Slack adapter's last hand-built Web API requests onto slackapi. The adapter built its own JSON bodies for auth.test, chat.postMessage, chat.postEphemeral, and conversations.open, next to typed slackapi methods for the same calls. #98 was that kind of bug: the adapter sent conversations.history as JSON while slackapi sent the form body that Slack accepts.

What changed

  • slackapi gains OpenConversation and a Mrkdwn field on PostMessageRequest and PostEphemeralRequest. These are the two requests the adapter sent that the typed methods could not express.
  • Init, PostMessage, PostEphemeralMessage, and the DM fallback call AuthTest, PostMessage, PostEphemeral, and OpenConversation. The adapter's seven private request and response structs and its call and callWithToken wrappers are gone.

Scope

  • PostNative still sends its payload through Client.Call. The typed request takes []Block, and the how-to guide promises that the adapter does not decode or check a native payload. Moving it would make the adapter reject payloads that it forwards today.
  • views.open has no typed method and stays on Client.Call.
  • No adapter test changed.

Blast Radius

Every outbound post from the adapter goes through the new call sites, and Slack receives the same request bodies. SentMessage.Raw for these posts now holds *slackapi.PostMessageResponse or *slackapi.PostEphemeralResponse instead of an unexported struct that no caller could name.

Verification

  • go test ./adapters/slack/... passes on main and on this branch with the same 91 top-level adapter tests.
  • A recording httptest server ran 27 adapter cases (31 requests) on both commits. 27 bodies are byte-identical. The other 4 are threaded chat.postEphemeral bodies with the same JSON and user before thread_ts. The path, content type, token, returned IDs, and error strings match in every case.
  • New slackapi tests pin {"users":"U1"} for conversations.open and "mrkdwn": false for both chat methods.

Closes #100


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

The Slack adapter sends mrkdwn:false with plain-text posts, and it opens a
DM with conversations.open for its ephemeral fallback. The typed methods
could not express either request, so the adapter built those bodies itself.

The new tests pin the JSON bodies that the adapter sends today.
Init, PostMessage, PostEphemeralMessage, and the DM fallback now call
AuthTest, PostMessage, PostEphemeral, and OpenConversation. The adapter's
own request and response structs and its call and callWithToken wrappers
are gone, so each of these methods has one request encoding.

PostNative still sends its opaque payload through Client.Call. The typed
request takes []Block, and the adapter docs promise that the payload is not
decoded or checked.

The request bodies are the same, except that the keys of a threaded
chat.postEphemeral body come in a different order. SentMessage.Raw now
holds the slackapi response type instead of an unexported struct.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T21:19:14.012904Z 2d5bd8e Manual request
🔒 Security Review ✅ Completed 2026-10-29T21:19:41.578054Z 2d5bd8e Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 486770601e

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 486770601e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 2d5bd8ea2e

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 2d5bd8ea2e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 merged commit 4e9fcf6 into main Oct 29, 2026
2 checks passed
ThomasK33 added a commit that referenced this pull request Oct 29, 2026
…retry docs (#137)

## Why

The operator wants every open follow-up issue in coder/chat closed by one small, reviewed PR. This PR closes the five Slack adapter and retry-doc follow-ups from the reviews of #132 and #133, as the triage comment on #136 decided them.

## What changed

- `chat.postEphemeral` no longer gets a `mrkdwn` field. Slack lists no such argument for that method, so `slackapi.PostEphemeralRequest` loses `Mrkdwn`. The DM fallback keeps `"mrkdwn": false` on `chat.postMessage`, and a test now pins it.
- The `withDefaults` comment states the real worst-case backoff: 2s (`MaxElapsed`) with a Slack `Retry-After`, not about 600ms. ADR 0005 decision 3 now states only the bounds, with a dated amendment note that points to #132. Decision 4 and two Consequences drop the same ack-window claim.
- A comment at the `PostNative` payload says why it skips the typed `PostMessage`: `[]slackapi.Block` models only three block types, and the docs call the payload opaque Block Kit.

Closes #136

## Scope

- No caller or test relied on `mrkdwn: false` for literal ephemeral text, so the text gets no escape.
- Plain Text in a native ephemeral message keeps Slack's mrkdwn parsing. Slack has no `mrkdwn` argument on `chat.postEphemeral`, so the dropped field likely never turned parsing off. I did not verify this against a live workspace. CONTEXT.md and the interactive-components how-to now record this exception.
- `adapters/linear/retry.go` had the same stale 600ms comment, and this PR corrects it too.

## Blast Radius

`slackapi.PostEphemeralRequest.Mrkdwn` is an exported field, so a caller that sets it stops compiling. The field had no documented effect on Slack.

## Verification

- The two new ephemeral tests fail on the test commit and pass on the fix commit. The DM-fallback test fails when the fallback stops sending `mrkdwn`.
- A local 429 server that always sends `Retry-After: 1` made the default policy return `RateLimited` after 2.01s and three attempts.
- `go vet`, `go test` for every module, `gofmt -l`, and `go test -race ./adapters/slack/...` pass.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
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.

refactor(adapters/slack): move remaining adapter calls onto typed slackapi methods

1 participant