(
input: ValidateConnectionInput,
)
| 5313 | ); |
| 5314 | |
| 5315 | const connectionValidate = ( |
| 5316 | input: ValidateConnectionInput, |
| 5317 | ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> => |
| 5318 | Effect.gen(function* () { |
| 5319 | const integrationRow = yield* findIntegrationRow(input.integration); |
| 5320 | if (!integrationRow) { |
| 5321 | return yield* new IntegrationNotFoundError({ |
| 5322 | slug: input.integration, |
| 5323 | }); |
| 5324 | } |
| 5325 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 5326 | const check = runtime?.plugin.checkHealth; |
| 5327 | if (!runtime || !check) return unknownHealth(); |
| 5328 | |
| 5329 | const values = yield* resolveInFlightValues(input); |
| 5330 | const record = rowToIntegrationRecord( |
| 5331 | integrationRow, |
| 5332 | yield* describeAuthMethodsForRow(integrationRow), |
| 5333 | ); |
| 5334 | const credential: ToolInvocationCredential = { |
| 5335 | owner: input.owner, |
| 5336 | integration: input.integration, |
| 5337 | // No connection exists yet (key-first); a synthetic name keeps the |
| 5338 | // credential shape whole. The probe authenticates on values+template, |
| 5339 | // not on this name (it only appears in upstream-error messages). |
| 5340 | connection: ConnectionName.make("(unsaved)"), |
| 5341 | template: input.template, |
| 5342 | value: values[PRIMARY_INPUT_VARIABLE] ?? null, |
| 5343 | values, |
| 5344 | config: record.config, |
| 5345 | }; |
| 5346 | // Caller override (editor preview) wins; otherwise the declared spec |
| 5347 | // from the integration row. Nothing persists here: validate is the |
| 5348 | // key-first flow's dry run. |
| 5349 | const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined; |
| 5350 | const result = yield* foldPluginFailure( |
| 5351 | check({ ctx: runtime.ctx, integration: record, credential, spec }), |
| 5352 | `Validating credential for "${input.integration}" failed.`, |
| 5353 | ); |
| 5354 | // Nothing persists here BY DESIGN, which makes this span the only |
| 5355 | // possible record of "what fraction of pasted credentials are rejected |
| 5356 | // at the door" — a signal the DB can never carry. |
| 5357 | yield* Effect.annotateCurrentSpan({ |
| 5358 | "executor.health.status": result.status, |
| 5359 | ...(result.httpStatus !== undefined |
| 5360 | ? { "executor.health.http_status": result.httpStatus } |
| 5361 | : {}), |
| 5362 | }); |
| 5363 | return result; |
| 5364 | }).pipe( |
| 5365 | Effect.withSpan("executor.connection.validate", { |
| 5366 | attributes: { |
| 5367 | "executor.tenant": tenant, |
| 5368 | ...(subject != null ? { "executor.subject": subject } : {}), |
| 5369 | "executor.integration": String(input.integration), |
| 5370 | }, |
| 5371 | }), |
| 5372 | ); |
nothing calls this directly
no test coverage detected