🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(slack): return 400 for invalid OAuth callback parameters (#15489)
Steffen Schmitz75a3e9047c2a
diff --git a/web/src/features/slack/server/oauth-handlers.ts b/web/src/features/slack/server/oauth-handlers.tsindex 28493ebbe6..27f0833d18 100644--- a/web/src/features/slack/server/oauth-handlers.ts+++ b/web/src/features/slack/server/oauth-handlers.ts@@ -11,6 +11,21 @@ import { prisma } from "@langfuse/shared/src/db";import { getSafeRedirectPath } from "@/src/utils/redirect";import { getProductBaseUrl } from "@/src/utils/base-url";+// ErrorCode values from @slack/oauth for callbacks that fail because of the+// client's request — no/invalid `code`/`state` (scanners, expired installs)+// or the user cancelling on Slack's consent screen — rather than because+// anything failed on our side. Within InstallProvider.handleCallback the+// authorization-error code is thrown only for `error=access_denied`+// (user cancel); token-exchange failures carry @slack/web-api codes instead.+// Kept as literals since web does not depend on @slack/oauth directly;+// unknown codes fall through to 500.+const SLACK_OAUTH_CLIENT_INPUT_ERROR_CODES = new Set<string>([+ "slack_oauth_missing_state",+ "slack_oauth_invalid_state",+ "slack_oauth_missing_code",+ "slack_oauth_installer_authorization_error",+]);+/*** SlackOAuthHandlers*@@ -119,7 +134,20 @@ export async function handleCallback(},failure: async (error) => {- logger.error("OAuth callback failed", { error: error.message });+ if (SLACK_OAUTH_CLIENT_INPUT_ERROR_CODES.has(error.code)) {+ logger.warn("OAuth callback rejected", {+ error: error.message,+ code: error.code,+ });+ res+ .status(400)+ .json({ message: "Invalid OAuth callback parameters" });+ return;+ }+ logger.error("OAuth callback failed", {+ error: error.message,+ code: error.code,+ });res.status(500).json({ message: "Internal server error" });},});