(
input: ValidateConnectionInput,
)
| 4742 | ); |
| 4743 | |
| 4744 | const connectionValidate = ( |
| 4745 | input: ValidateConnectionInput, |
| 4746 | ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> => |
| 4747 | Effect.gen(function* () { |
| 4748 | const integrationRow = yield* findIntegrationRow(input.integration); |
| 4749 | if (!integrationRow) { |
| 4750 | return yield* new IntegrationNotFoundError({ slug: input.integration }); |
| 4751 | } |
| 4752 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 4753 | const check = runtime?.plugin.checkHealth; |
| 4754 | if (!runtime || !check) return unknownHealth(); |
| 4755 | |
| 4756 | const values = yield* resolveInFlightValues(input); |
| 4757 | const record = rowToIntegrationRecord( |
| 4758 | integrationRow, |
| 4759 | describeAuthMethodsForRow(integrationRow), |
| 4760 | ); |
| 4761 | const credential: ToolInvocationCredential = { |
| 4762 | owner: input.owner, |
| 4763 | integration: input.integration, |
| 4764 | // No connection exists yet (key-first); a synthetic name keeps the |
| 4765 | // credential shape whole. The probe authenticates on values+template, |
| 4766 | // not on this name (it only appears in upstream-error messages). |
| 4767 | connection: ConnectionName.make("(unsaved)"), |
| 4768 | template: input.template, |
| 4769 | value: values[PRIMARY_INPUT_VARIABLE] ?? null, |
| 4770 | values, |
| 4771 | config: record.config, |
| 4772 | }; |
| 4773 | // Caller override (editor preview) wins; otherwise the declared spec |
| 4774 | // from the integration row. Nothing persists here: validate is the |
| 4775 | // key-first flow's dry run. |
| 4776 | const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined; |
| 4777 | const result = yield* foldPluginFailure( |
| 4778 | check({ ctx: runtime.ctx, integration: record, credential, spec }), |
| 4779 | `Validating credential for "${input.integration}" failed.`, |
| 4780 | ); |
| 4781 | // Nothing persists here BY DESIGN, which makes this span the only |
| 4782 | // possible record of "what fraction of pasted credentials are rejected |
| 4783 | // at the door" — a signal the DB can never carry. |
| 4784 | yield* Effect.annotateCurrentSpan({ |
| 4785 | "executor.health.status": result.status, |
| 4786 | ...(result.httpStatus !== undefined |
| 4787 | ? { "executor.health.http_status": result.httpStatus } |
| 4788 | : {}), |
| 4789 | }); |
| 4790 | return result; |
| 4791 | }).pipe( |
| 4792 | Effect.withSpan("executor.connection.validate", { |
| 4793 | attributes: { |
| 4794 | "executor.tenant": tenant, |
| 4795 | ...(subject != null ? { "executor.subject": subject } : {}), |
| 4796 | "executor.integration": String(input.integration), |
| 4797 | }, |
| 4798 | }), |
| 4799 | ); |
| 4800 | |
| 4801 | // Clear the sync stamp so the next tools read re-produces this connection's |
nothing calls this directly
no test coverage detected