MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / connectionValidate

Function connectionValidate

packages/core/sdk/src/executor.ts:3388–3443  ·  view source on GitHub ↗
(
      input: ValidateConnectionInput,
    )

Source from the content-addressed store, hash-verified

3386 );
3387
3388 const connectionValidate = (
3389 input: ValidateConnectionInput,
3390 ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> =>
3391 Effect.gen(function* () {
3392 const integrationRow = yield* findIntegrationRow(input.integration);
3393 if (!integrationRow) {
3394 return yield* new IntegrationNotFoundError({ slug: input.integration });
3395 }
3396 const runtime = runtimes.get(integrationRow.plugin_id);
3397 const check = runtime?.plugin.checkHealth;
3398 if (!runtime || !check) return unknownHealth();
3399
3400 const values = yield* resolveInFlightValues(input);
3401 const record = rowToIntegrationRecord(
3402 integrationRow,
3403 describeAuthMethodsForRow(integrationRow),
3404 );
3405 const credential: ToolInvocationCredential = {
3406 owner: input.owner,
3407 integration: input.integration,
3408 // No connection exists yet (key-first); a synthetic name keeps the
3409 // credential shape whole. The probe authenticates on values+template,
3410 // not on this name (it only appears in upstream-error messages).
3411 connection: ConnectionName.make("(unsaved)"),
3412 template: input.template,
3413 value: values[PRIMARY_INPUT_VARIABLE] ?? null,
3414 values,
3415 config: record.config,
3416 };
3417 // Caller override (editor preview) wins; otherwise the declared spec
3418 // from the integration row. Nothing persists here: validate is the
3419 // key-first flow's dry run.
3420 const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined;
3421 const result = yield* foldPluginFailure(
3422 check({ ctx: runtime.ctx, integration: record, credential, spec }),
3423 `Validating credential for "${input.integration}" failed.`,
3424 );
3425 // Nothing persists here BY DESIGN, which makes this span the only
3426 // possible record of "what fraction of pasted credentials are rejected
3427 // at the door" — a signal the DB can never carry.
3428 yield* Effect.annotateCurrentSpan({
3429 "executor.health.status": result.status,
3430 ...(result.httpStatus !== undefined
3431 ? { "executor.health.http_status": result.httpStatus }
3432 : {}),
3433 });
3434 return result;
3435 }).pipe(
3436 Effect.withSpan("executor.connection.validate", {
3437 attributes: {
3438 "executor.tenant": tenant,
3439 ...(subject != null ? { "executor.subject": subject } : {}),
3440 "executor.integration": String(input.integration),
3441 },
3442 }),
3443 );
3444
3445 // Clear the sync stamp so the next tools read re-produces this connection's

Callers

nothing calls this directly

Calls 9

findIntegrationRowFunction · 0.85
unknownHealthFunction · 0.85
resolveInFlightValuesFunction · 0.85
rowToIntegrationRecordFunction · 0.85
foldPluginFailureFunction · 0.85
getMethod · 0.65
checkFunction · 0.50

Tested by

no test coverage detected