Skip to content

[Fix] Derive SLACK_AUTH_URI from ROOMOTE_APP_URL when unset - #95

Merged
mrubens merged 1 commit into
developfrom
claude/sleepy-leavitt-1c87b5
Jul 10, 2026
Merged

[Fix] Derive SLACK_AUTH_URI from ROOMOTE_APP_URL when unset#95
mrubens merged 1 commit into
developfrom
claude/sleepy-leavitt-1c87b5

Conversation

@mrubens

@mrubens mrubens commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

When SLACK_AUTH_URI is unset, the Slack account-linking onboarding DM silently fails. The env schema defaults it to an empty string, so the "Link accounts" button URL becomes ?state=<token> — Slack rejects the entire chat.postMessage with invalid_blocks ("invalid url"), and unlinked users who DM the bot get no response at all.

This hit the roomote-nightly Railway deployment on 2026-07-10: none of the fleet deployments set SLACK_AUTH_URI (the ops provision script only sets ROOMOTE_APP_URL).

Fix

When SLACK_AUTH_URI is unset or empty, derive it from ROOMOTE_APP_URL as ${ROOMOTE_APP_URL}/api/slack/auth — the route the web app already serves for completing the link (apps/web/src/app/api/slack/auth/route.ts). An explicitly set SLACK_AUTH_URI still wins.

The fallback lives in buildRoomoteRuntimeEnv (packages/env) rather than at the button-building site, so every service that constructs env — including rehydrateEnv and the web bootstrap — gets it, matching the existing derivation pattern for SLACK_API_TIMEOUT_MS and DOCKER_WORKER_IMAGE.

Changes

  • packages/env/src/index.ts — derive SLACK_AUTH_URI from ROOMOTE_APP_URL when unset/empty (trailing slashes trimmed)
  • packages/env/src/__tests__/index.test.ts — tests for the fallback (unset, empty, trailing slash) and explicit-override precedence
  • apps/docs/environment-variables.mdx — document the default

Validation

  • pnpm --filter @roomote/env exec vitest run src/__tests__/index.test.ts — 53 passed
  • pnpm --filter @roomote/slack exec vitest run src/__tests__/block-kit.test.ts — 21 passed
  • pnpm lint and pnpm check-types — clean across all workspaces

No fleet config change needed: deployments already set ROOMOTE_APP_URL, so the next deploy with this commit fixes the silent DM failure.

@roomote-roomote

roomote-roomote Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

Verified the fallback lives in buildRoomoteRuntimeEnv, so it flows through createRoomoteEnv, rehydrateEnv, and the shared Env proxy for every service. The derived ${ROOMOTE_APP_URL}/api/slack/auth matches the route that reads ?state= (apps/web/src/app/api/slack/auth/route.ts) and is consistent with ecosystem.config.js. Precedence (explicit wins), empty/unset handling, and trailing-slash trimming are all correct, and docs/tests are in sync.

@mrubens

mrubens commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@openmote should we do the same for SLACK_REDIRECT_URI?

@roomote-roomote-v1

Copy link
Copy Markdown

I saw the mention, but I could not process it right now because the GitHub follow-up context was incomplete. Please try again in a moment.

@mrubens
mrubens merged commit bd08efc into develop Jul 10, 2026
@mrubens
mrubens deleted the claude/sleepy-leavitt-1c87b5 branch July 10, 2026 16:34
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