AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(builder): opening an imported step with a missing connection no longer wipes its values (#16131)
Othman Abu Ajamieh90fed1a3cbff
diff --git a/brain/knowledge/flows-execution/templates.md b/brain/knowledge/flows-execution/templates.mdindex a14240db551..cf5cc3452a4 100644--- a/brain/knowledge/flows-execution/templates.md+++ b/brain/knowledge/flows-execution/templates.md@@ -23,6 +23,7 @@ Templates are a library of reusable flow (and table) blueprints users can browse- OFFICIAL and SHARED templates cannot be updated or deleted via API; ownership is double-checked (`template.platformId === principal.platform.id`).- Flow version migration (`migrateFlowVersionTemplateList`) runs as a `preValidation` hook on create/update to handle schema evolution in stored flows.- `pieces` and `categories` are denormalized + indexed for fast filtering.+- **A flow export (`GET /v1/flows/:id/template`) keeps its connection refs.** `removeConnectionsFromInput` in `flow-version.service.ts` strips only the old `{{connections.x}}` dot syntax, and the builder has written `{{connections['x']}}` since 2023. Import keeps the ref, so a flow re-imported where a connection with that External ID exists just works, and users rely on it. Fixing the regex is a functional breaking change, not a cleanup (GIT-1957).- **`POST /v1/templates-telemetry/event` serves two callers, and only one of them is the relay — do not gate it on edition or skip the gate.** It is `securityAccess.public()`, and the local browser posts to it directly for VIEW, INSTALL and EXPLORE_VIEW (`packages/web/src/features/templates/api/templates-telemetry-api.ts`, four call sites); a self-hosted instance *also* posts to Cloud's copy of the same route via `sendToCloud`. Those three event types travel **only** this path, so treating the route as "the relay hop, already consented upstream" silently un-gates them for every opted-out self-hoster. The controller therefore resolves `platformUtils.getPlatformIdForRequest` and the service gates on that platform's row when one resolves; a null platform means the genuine relay case (a Cloud request with no principal, whose `projectId`/`templateId` belong to the sending deployment's database) and is forwarded. ACTIVATE/DEACTIVATE come from `trigger-source-service` with a real `projectId` and are gated through the project. Also note `sendToCloud`/`sendToInternal` use raw `fetch`, not `safeHttp`/`apAxios` — pre-existing, and only sound because both URLs are hardcoded.diff --git a/brain/knowledge/pieces-engine/pieces.md b/brain/knowledge/pieces-engine/pieces.mdindex bf10362cf25..7901d3cc181 100644--- a/brain/knowledge/pieces-engine/pieces.md+++ b/brain/knowledge/pieces-engine/pieces.md@@ -30,7 +30,7 @@ The metadata catalog of automation integrations ("pieces") — each a named inte- `DynamicPropertiesContext` tracks loading by property name only, so two in-flight requests for the same property let the first completion clear the flag for both — briefly re-enabling Test Step while the value is still cleared.- **`POST /v1/pieces/options` cost scales with the whole flow's sample data, not with the property being resolved.** The handler builds an `EXECUTE_PROPERTY` job whose payload carries `sampleData` — and `getSampleDataForFlow` reads *every* step's sample-data `file` row. That payload then crosses Postgres → API → Redis → worker → engine socket, so a big flow pays megabytes to resolve a trivial resolver like the HTTP piece's `authFields`: measured 7.3 MB on a 25-step flow, and a panel open fires three of these in parallel (GIT-1822). The engine only uses `sampleData` to seed step outputs so `{{step.x}}` inside the property's `input` resolves, so callers must use `getSampleDataReferencedBy` and pass the request `input` — which narrows the read to the steps that input names. When narrowing, a referenced `LOOP_ON_ITEMS` step also needs whatever its `items` expression references: `stateFromFlowVersion` derives a loop's `item` by resolving its settings against the context built so far, never from `sampleData[loopName]`. Matching step names as substrings of the serialized input over-approximates, which is the safe direction — a step reference always spells the name literally, in both the property-path and script branches of `props-resolver`.- **There is no static signal for whether a DynamicProperties resolver is pure, so caching its result is never safe by inspection.** Both tempting heuristics have counterexamples in this repo. "Trivial resolver" fails because purity cannot be read off the declaration; "declares no connection" fails because `packages/pieces/core/tables` `update-record` declares `auth: PieceAuth.None()` yet its `values` resolver calls `tablesCommon.createFieldProperties` → `getTableFields`, a live request to `v1/fields` authenticated with the **engine token** rather than a connection — so a column added to an Activepieces Table would not show up. Third-party resolvers that fetch live schema (Zendesk `userFieldsDynamicProp`, Supabase `table_columns`) are the same class reached through a connection. The failure mode is a silently outdated form, which the builder gives the user no way to refresh. Anything in this area (GIT-813) needs either a purity signal the piece declares, or stale-while-revalidate that always refetches and corrects within a round trip — and note that SWR re-applies the schema a second time, which is exactly the path the `lastKnownValue` snapshot above exists to protect.-- **The frontend `POST /v1/pieces/options` client only rejects for DYNAMIC.** `piecesApi.options` (`packages/web/src/features/pieces/api/`) catches DROPDOWN failures, toasts, and *resolves* with a disabled-dropdown fallback — so for dropdowns every error path wired onto that mutation is dead: `usePieceOptions`' `onError` handlers, its `retry: 1`, and the `if (error) throw error` into `DynamicPropertiesErrorBoundary`. DYNAMIC must rethrow: a swallowed failure arrives as a *successful* empty schema, which resets the property's children to defaults and gets persisted by step-settings autosave.+- **The frontend `POST /v1/pieces/options` client only rejects for DYNAMIC.** `piecesApi.options` (`packages/web/src/features/pieces/api/`) catches DROPDOWN failures, toasts, and *resolves* with a disabled-dropdown fallback — so for dropdowns every error path wired onto that mutation is dead: `usePieceOptions`' `onError` handlers, its `retry: 1`, and the `if (error) throw error` into `DynamicPropertiesErrorBoundary`. DYNAMIC must rethrow: a swallowed failure arrives as a *successful* empty schema, which resets the property's children to defaults and gets persisted by step-settings autosave. The engine swallows failures too: `executeProps` turns any non-engine error (a missing or revoked connection, a resolver that throws) into the disabled-dropdown placeholder with status OK, and an `INTERNAL_ERROR` job comes back as a 200 with an empty body. So for DYNAMIC the client also rejects any response whose `options` is not a property map; an empty map `{}` is valid (GIT-1957).- **An action that can be called as an MCP tool cannot create a waitpoint.** An MCP piece tool runs thereal action through `actionRunService`, which sets `actionRunMode` on the engine, and`createWaitpoint` / `waitForWaitpoint` both throw `assertActionRunCannotSuspend` there. So an actiondiff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex cd9d0025d29..aa5839eb1ab 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -1,4 +1,5 @@{+ "Connection not found": "Connection not found","You must include these actions to publish.": "You must include these actions to publish.","You must include one of these actions to publish.": "You must include one of these actions to publish.","At least one": "At least one",diff --git a/packages/web/src/app/builder/piece-properties/dynamic-piece-property.tsx b/packages/web/src/app/builder/piece-properties/dynamic-piece-property.tsxindex 80b553eb617..5c4d1b9d63c 100644--- a/packages/web/src/app/builder/piece-properties/dynamic-piece-property.tsx+++ b/packages/web/src/app/builder/piece-properties/dynamic-piece-property.tsx@@ -11,7 +11,6 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';import { useBuilderStateContext } from '@/app/builder/builder-hooks';import { SkeletonList } from '@/components/ui/skeleton';-import { internalErrorToast } from '@/components/ui/sonner';import { piecesHooks, formUtils } from '@/features/pieces';import { authenticationSession } from '@/lib/authentication-session';@@ -78,7 +77,6 @@ const DynamicPropertiesImplementation = React.memo(},onError: (error) => {console.error(error);- internalErrorToast();propertyLoadingFinished(props.propertyName);},onSuccess: () => {diff --git a/packages/web/src/app/builder/step-settings/piece-settings/connection-select.tsx b/packages/web/src/app/builder/step-settings/piece-settings/connection-select.tsxindex 8f08b2c5c4c..0c028156a30 100644--- a/packages/web/src/app/builder/step-settings/piece-settings/connection-select.tsx+++ b/packages/web/src/app/builder/step-settings/piece-settings/connection-select.tsx@@ -222,31 +222,10 @@ function ConnectionSelect(params: ConnectionSelectProps) {placeholder={t('Select a connection')}data-testid="select-connection-value">- {!isNil(field.value) &&- !isNil(- connections?.data?.find(- (connection) =>- connection.externalId ===- removeBrackets(field.value),- ),- ) ? (- <div className="truncate grow shrink flex items-center gap-2">- {connections?.data?.find(- (connection) =>- connection.externalId ===- removeBrackets(field.value),- )?.scope === AppConnectionScope.PLATFORM && (- <Globe size={16} className="shrink-0" />- )}- {- connections?.data?.find(- (connection) =>- connection.externalId ===- removeBrackets(field.value),- )?.displayName- }- </div>- ) : null}+ <SelectedConnectionLabel+ value={field.value}+ connections={connections?.data ?? []}+ /></SelectValue><div className="grow"></div>{field.value &&@@ -377,6 +356,36 @@ function removeBrackets(str: string | undefined) {(_, connectionName) => connectionName,);}+function SelectedConnectionLabel({+ value,+ connections,+}: {+ value: string | undefined;+ connections: AppConnectionWithoutSensitiveData[];+}) {+ if (isNil(value) || value === '') {+ return null;+ }+ const connection = connections.find(+ (connection) => connection.externalId === removeBrackets(value),+ );+ if (isNil(connection)) {+ return (+ <div className="truncate grow shrink flex items-center gap-2 text-gray-11">+ <Unplug size={16} className="shrink-0 text-danger-11" />+ {t('Connection not found')}+ </div>+ );+ }+ return (+ <div className="truncate grow shrink flex items-center gap-2">+ {connection.scope === AppConnectionScope.PLATFORM && (+ <Globe size={16} className="shrink-0" />+ )}+ {connection.displayName}+ </div>+ );+}function getConnectionStatusDisplay(status: AppConnectionStatus): {Icon: LucideIcon;iconClassName: string;diff --git a/packages/web/src/features/pieces/api/pieces-api.ts b/packages/web/src/features/pieces/api/pieces-api.tsindex 0eba9c1fcb0..6ed62fe2e5d 100644--- a/packages/web/src/features/pieces/api/pieces-api.ts+++ b/packages/web/src/features/pieces/api/pieces-api.ts@@ -44,6 +44,15 @@ export const piecesApi = {): Promise<ExecutePropsResult<T>> {return api.post<ExecutePropsResult<T>>(`/v1/pieces/options`, request)+ .then((response) => {+ if (+ propertyType === PropertyType.DYNAMIC &&+ !hasPropertyMapOptions(response)+ ) {+ throw new Error('Dynamic properties did not resolve to a schema');+ }+ return response;+ }).catch((error) => {if (propertyType === PropertyType.DYNAMIC) {throw error;@@ -97,3 +106,23 @@ export const piecesApi = {return api.delete(`/v1/pieces/${id}`);},};++function hasPropertyMapOptions(response: unknown): boolean {+ if (!isObject(response) || !('options' in response)) {+ return false;+ }+ const { options } = response;+ return (+ isObject(options) &&+ Object.values(options).every(+ (property) =>+ isObject(property) &&+ 'type' in property &&+ typeof property.type === 'string',+ )+ );+}++function isObject(value: unknown): value is object {+ return typeof value === 'object' && value !== null && !Array.isArray(value);+}diff --git a/packages/web/test/features/pieces/pieces-api.test.ts b/packages/web/test/features/pieces/pieces-api.test.tsindex 51c70414a77..6004cc6de40 100644--- a/packages/web/test/features/pieces/pieces-api.test.ts+++ b/packages/web/test/features/pieces/pieces-api.test.ts@@ -31,6 +31,64 @@ describe('piecesApi.options', () => {).rejects.toBe(failure);});+ it('rejects for DYNAMIC when the engine answers with the dropdown placeholder', async () => {+ post.mockResolvedValue({+ type: PropertyType.DYNAMIC,+ options: {+ disabled: true,+ options: [],+ placeholder: 'Throws an error, reconnect or refresh the page',+ },+ });++ await expect(+ piecesApi.options(request, PropertyType.DYNAMIC),+ ).rejects.toThrow();+ });++ it('rejects for DYNAMIC when the engine answers with an empty body', async () => {+ post.mockResolvedValue('');++ await expect(+ piecesApi.options(request, PropertyType.DYNAMIC),+ ).rejects.toThrow();+ });++ it('resolves for DYNAMIC when the engine answers with a property map', async () => {+ const response = {+ type: PropertyType.DYNAMIC,+ options: {+ url: { type: PropertyType.SHORT_TEXT, displayName: 'URL' },+ },+ };+ post.mockResolvedValue(response);++ await expect(+ piecesApi.options(request, PropertyType.DYNAMIC),+ ).resolves.toBe(response);+ });++ it('resolves for DYNAMIC when the engine answers with an empty property map', async () => {+ const response = { type: PropertyType.DYNAMIC, options: {} };+ post.mockResolvedValue(response);++ await expect(+ piecesApi.options(request, PropertyType.DYNAMIC),+ ).resolves.toBe(response);+ });++ it('resolves the engine placeholder unchanged for DROPDOWN', async () => {+ const response = {+ type: PropertyType.DROPDOWN,+ options: { disabled: true, options: [], placeholder: 'reconnect' },+ };+ post.mockResolvedValue(response);++ await expect(+ piecesApi.options(request, PropertyType.DROPDOWN),+ ).resolves.toBe(response);+ });+it('resolves a disabled dropdown state for DROPDOWN', async () => {post.mockRejectedValue(new Error('boom'));