Adds a new authorization_params shape that lets a toolkit declare a URL query parameter whose inclusion is conditional on the runtime-templated value being non-empty:
import { optionalAuthParam } from '@composiohq/auth-config'
authorization_params: {
response_type: 'code',
user_scopes: 'admin',
team: optionalAuthParam('{{team}}'),
}
When the connection_data resolves team to 'T0XYZ', the URL gets team=T0XYZ. When it's empty/unset, the param is omitted entirely (not emitted as team=).
Slack's team query param scopes consent to a workspace, but emitting team= (empty) is functionally wrong — Slack accepts the call but ignores the scoping, letting users pick any workspace (see QA report on staging).
The previous attempt at mercury#22425 used a (fields) => ({ ...(fields.team ? {team: fields.team} : {}) }) callback. That runs at config-build time where fields.team is the template placeholder '{{team}}' (always truthy), so the resulting config.json always carried team: '{{team}}'. At runtime, the empty {{team}} resolved to an empty string and the URL emitted team=. The whole rollout was reverted in mercury#23427.
eval_fields already covers the related Microsoft issuer case (path-segment substitution, where the "common" default is meaningful) but cannot omit a query param entirely. That's what this PR adds.
packages/auth-config (bumped 0.1.21 → 0.1.22):
lib/authParams.ts — ConditionalAuthParamSchema, AuthParamValueSchema (string | ConditionalAuthParam), optionalAuthParam(value) helper, plus isConditionalAuthParam / resolveAuthParamValue runtime helpersbase.ts — both OAuth1 and OAuth2 authorization_params widened from .catchall(z.unknown()) to .catchall(AuthParamValueSchema). Explicit known keys remain string-typed (backward-compatible).conditionalAuthParams.test.ts covering: compiled wire shape, callback return form, Zod round-trip, invalid-shape rejection, type-guard behavior. Per reviewer guidance, this is the in-package iterate-fast loop.apps/apollo:
oAuth2.ts:getAuthorizationUrl — replaces searchParams.set(key, value as string) with resolveAuthParamValue(value) + skip when undefined.oAuth1.ts:authURL — same treatment before spreading into URLSearchParams (previously would have stringified an object as [object Object]).oAuth2.authParams.unit.test.ts — fabricates an OAuth2 scheme and asserts URL emits the param when staged, omits it when empty, and mixes conditional + static cases.Existing string-valued authorization_params are unchanged. Configs that previously sent team= (empty) keep doing so until they migrate to optionalAuthParam. Microsoft issuer stays on eval_fields (correct shape there).
pnpm --filter @composiohq/auth-config test — 75 passed (6 new + 69 existing)vitest.unit.config.ts locally) — 535 passed (4 new + 531 existing)@composiohq/auth-config@0.1.22 auto-publishesfeat/conditional-auth-params (ComposioHQ/mercury) consumes the new packagemercury.registry.push to staging thermos → reproduce QA curl, confirm team=T0... when staged and no team= when unstagedfeat/conditional-auth-params, depends on this PR)🤖 Generated with Claude Code
Based on git blame analysis of 8 file(s):
| Contributor | Contribution | Files |
|---|---|---|
| Sarthak Agrawal | 36% | 2 |
| lingalarahul7 | 33% | 5 |
| Rahul Tarak | 11% | 4 |
| Himanshu Dixit | 6% | 3 |
| Karthikeya-Meesala | 6% | 2 |
Based on git history, Sarthak Agrawal or lingalarahul7 would be good reviewer(s) for this PR.
🤖 Based on git blame with recency weighting (recent edits count more).
:x: Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| apps/apollo/src/lib/connected_accounts/oAuth1.ts | 8.33% | 11 Missing :warning: |
| Flag | Coverage Δ | |
|---|---|---|
| e2e-tests | 5.76% <0.00%> (-0.01%) | :arrow_down: |
| self-hosted-tests | 5.58% <0.00%> (-0.01%) | :arrow_down: |
| thermos-unit-tests | ? | |
| unit-tests | 58.32% <38.88%> (-0.01%) | :arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| apps/apollo/src/lib/connected_accounts/oAuth2.ts | 78.12% <100.00%> (+0.32%) | :arrow_up: |
| apps/apollo/src/lib/connected_accounts/oAuth1.ts | 7.21% <8.33%> (+0.11%) | :arrow_up: |
... and 263 files with indirect coverage changes