#15625·activepieces

[Pieces framework] Two auth methods of the same type silently resolve to the first one

Author: bst1nCreated Sep 18, 2026Updated Sep 30, 2026

Summary

A piece can declare several authentication methods as an array (auth: [a, b]), and the UI renders a method picker for it. But the platform resolves which entry applies purely from the stored connection type:

typescript
// packages/pieces/framework/src/lib/property/authentication/index.ts
return pieceAuth.find(auth => authConnectionTypeToPropertyType[authValueType] === auth.type) ?? pieceAuth.at(0);

So two entries sharing a type — most commonly two CustomAuth — are indistinguishable, and the first one always wins. Nothing rejects this shape: the metadata schema is a plain array with no uniqueness constraint (packages/pieces/framework/src/lib/piece-metadata.ts), it type-checks, and the picker renders both methods correctly. The failure only appears when a user saves a connection.

What breaks

  • Validation runs against the wrong method. validateAuth in packages/server/engine/src/lib/helper/piece-helper.ts resolves through getAuthPropertyForValue, so the second method's credentials are checked by the first method's validate() — and rejected.
  • Reconnect preselects the wrong method (packages/web/src/app/connections/create-edit-connection-dialog.tsx).
  • refresh support is read off auth[0] unconditionally in packages/server/api/src/app/app-connection/app-connection-service/app-connection.handler.ts, so a refresh declared on a later entry is never detected.

Why it is hard to avoid

Only CUSTOM_AUTH and OIDC accept arbitrary fields. SecretText and BasicAuth take no extra field, so any method that needs its own URL must be a CustomAuth — which makes this bite precisely the self-hosted pieces, where each method needs an instance URL alongside the credentials.

Umami avoids it only by coincidence: its split is cloud (fixed URL → SecretText) vs self-hosted (CustomAuth), so the URL falls on one side. A piece whose methods split by credential kind rather than by hosting has no such escape.

OIDC technically accepts free-form props, but it means OpenID Connect identity federation (used by the AWS pieces for assume-role, with a server-signed key) — using it as a second CustomAuth slot would misrepresent the connection type in the database.

The workaround, and what it costs

The current fallback is a single CustomAuth holding every field from both methods, plus a StaticDropdown to name the intent and MarkDown blocks telling users to leave the other section blank — see packages/pieces/community/baserow/src/lib/auth.ts.

It cannot be improved, because CustomAuthProps only accepts static properties (no DynamicProperties, no refreshers), so there is no way to show or hide fields based on the dropdown. Every user sees every field of both methods on one page, and the dropdown is read only at runtime — the UI ignores it.

This has already cost the project

  • #12226 (merged 8 Apr) shipped Baserow with baserowAuth = [databaseTokenAuth, jwtAuth] — two CustomAuth.
  • #12504 was opened 9 Apr, the day after, following that pattern for Postiz.
  • #12759 (23 Apr) removed JWT auth from Baserow entirely; the array form did not work.
  • #12964 (29 Apr) restored it as the single-CustomAuth-plus-dropdown workaround above.
  • #12504 was closed 2 Jun: "Multiple auths of the same type (CustomAuth) are not supported in a piece." Correct — but the pattern it used was in main when it was written, and the replacement pattern had landed five weeks earlier.

Since nothing enforces the constraint, the next piece author will reach for the array form the same way.

Proposed direction

Give auth properties an explicit discriminator (e.g. an id), persist it on the connection, and resolve through it in getAuthPropertyForValue, falling back to the current type matching when absent. That is the smallest change that makes the existing multi-auth mechanism actually general, rather than adding a second mechanism alongside it.

Two things to settle before implementing:

  • Migration of existing connections. #14992 already reports that changing a piece's declared auth silently breaks connections created under the old shape — the same machinery, so the two should be designed together.
  • Whether to instead reject duplicate types at metadata validation, as a cheap first step, so the failure is loud at build time instead of silent at connection time.

Happy to implement this — raising it first so the direction can be agreed before any code, given it touches the framework, the engine, the server and the web app.

Source: activepieces/activepieces