(
input: ValidateConnectionInput,
)
| 4012 | ); |
| 4013 | |
| 4014 | const connectionValidate = ( |
| 4015 | input: ValidateConnectionInput, |
| 4016 | ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> => |
| 4017 | Effect.gen(function* () { |
| 4018 | const integrationRow = yield* findIntegrationRow(input.integration); |
| 4019 | if (!integrationRow) { |
| 4020 | return yield* new IntegrationNotFoundError({ slug: input.integration }); |
| 4021 | } |
| 4022 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 4023 | const check = runtime?.plugin.checkHealth; |
| 4024 | if (!runtime || !check) return unknownHealth(); |
| 4025 | |
| 4026 | const values = yield* resolveInFlightValues(input); |
| 4027 | const record = rowToIntegrationRecord( |
| 4028 | integrationRow, |
| 4029 | describeAuthMethodsForRow(integrationRow), |
| 4030 | ); |
| 4031 | const credential: ToolInvocationCredential = { |
| 4032 | owner: input.owner, |
| 4033 | integration: input.integration, |
| 4034 | // No connection exists yet (key-first); a synthetic name keeps the |
| 4035 | // credential shape whole. The probe authenticates on values+template, |
| 4036 | // not on this name (it only appears in upstream-error messages). |
| 4037 | connection: ConnectionName.make("(unsaved)"), |
| 4038 | template: input.template, |
| 4039 | value: values[PRIMARY_INPUT_VARIABLE] ?? null, |
| 4040 | values, |
| 4041 | config: record.config, |
| 4042 | }; |
| 4043 | // Caller override (editor preview) wins; otherwise the declared spec |
| 4044 | // from the integration row. Nothing persists here: validate is the |
| 4045 | // key-first flow's dry run. |
| 4046 | const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined; |
| 4047 | const result = yield* foldPluginFailure( |
| 4048 | check({ ctx: runtime.ctx, integration: record, credential, spec }), |
| 4049 | `Validating credential for "${input.integration}" failed.`, |
| 4050 | ); |
| 4051 | // Nothing persists here BY DESIGN, which makes this span the only |
| 4052 | // possible record of "what fraction of pasted credentials are rejected |
| 4053 | // at the door" — a signal the DB can never carry. |
| 4054 | yield* Effect.annotateCurrentSpan({ |
| 4055 | "executor.health.status": result.status, |
| 4056 | ...(result.httpStatus !== undefined |
| 4057 | ? { "executor.health.http_status": result.httpStatus } |
| 4058 | : {}), |
| 4059 | }); |
| 4060 | return result; |
| 4061 | }).pipe( |
| 4062 | Effect.withSpan("executor.connection.validate", { |
| 4063 | attributes: { |
| 4064 | "executor.tenant": tenant, |
| 4065 | ...(subject != null ? { "executor.subject": subject } : {}), |
| 4066 | "executor.integration": String(input.integration), |
| 4067 | }, |
| 4068 | }), |
| 4069 | ); |
| 4070 | |
| 4071 | // Clear the sync stamp so the next tools read re-produces this connection's |
nothing calls this directly
no test coverage detected