(
input: ValidateConnectionInput,
)
| 3432 | ); |
| 3433 | |
| 3434 | const connectionValidate = ( |
| 3435 | input: ValidateConnectionInput, |
| 3436 | ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> => |
| 3437 | Effect.gen(function* () { |
| 3438 | const integrationRow = yield* findIntegrationRow(input.integration); |
| 3439 | if (!integrationRow) { |
| 3440 | return yield* new IntegrationNotFoundError({ slug: input.integration }); |
| 3441 | } |
| 3442 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 3443 | const check = runtime?.plugin.checkHealth; |
| 3444 | if (!runtime || !check) return unknownHealth(); |
| 3445 | |
| 3446 | const values = yield* resolveInFlightValues(input); |
| 3447 | const record = rowToIntegrationRecord( |
| 3448 | integrationRow, |
| 3449 | describeAuthMethodsForRow(integrationRow), |
| 3450 | ); |
| 3451 | const credential: ToolInvocationCredential = { |
| 3452 | owner: input.owner, |
| 3453 | integration: input.integration, |
| 3454 | // No connection exists yet (key-first); a synthetic name keeps the |
| 3455 | // credential shape whole. The probe authenticates on values+template, |
| 3456 | // not on this name (it only appears in upstream-error messages). |
| 3457 | connection: ConnectionName.make("(unsaved)"), |
| 3458 | template: input.template, |
| 3459 | value: values[PRIMARY_INPUT_VARIABLE] ?? null, |
| 3460 | values, |
| 3461 | config: record.config, |
| 3462 | }; |
| 3463 | // Caller override (editor preview) wins; otherwise the declared spec |
| 3464 | // from the integration row. Nothing persists here: validate is the |
| 3465 | // key-first flow's dry run. |
| 3466 | const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined; |
| 3467 | const result = yield* foldPluginFailure( |
| 3468 | check({ ctx: runtime.ctx, integration: record, credential, spec }), |
| 3469 | `Validating credential for "${input.integration}" failed.`, |
| 3470 | ); |
| 3471 | // Nothing persists here BY DESIGN, which makes this span the only |
| 3472 | // possible record of "what fraction of pasted credentials are rejected |
| 3473 | // at the door" — a signal the DB can never carry. |
| 3474 | yield* Effect.annotateCurrentSpan({ |
| 3475 | "executor.health.status": result.status, |
| 3476 | ...(result.httpStatus !== undefined |
| 3477 | ? { "executor.health.http_status": result.httpStatus } |
| 3478 | : {}), |
| 3479 | }); |
| 3480 | return result; |
| 3481 | }).pipe( |
| 3482 | Effect.withSpan("executor.connection.validate", { |
| 3483 | attributes: { |
| 3484 | "executor.tenant": tenant, |
| 3485 | ...(subject != null ? { "executor.subject": subject } : {}), |
| 3486 | "executor.integration": String(input.integration), |
| 3487 | }, |
| 3488 | }), |
| 3489 | ); |
| 3490 | |
| 3491 | // Clear the sync stamp so the next tools read re-produces this connection's |
nothing calls this directly
no test coverage detected