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

Function connectionValidate

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

Source from the content-addressed store, hash-verified

3367 );
3368
3369 const connectionValidate = (
3370 input: ValidateConnectionInput,
3371 ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> =>
3372 Effect.gen(function* () {
3373 const integrationRow = yield* findIntegrationRow(input.integration);
3374 if (!integrationRow) {
3375 return yield* new IntegrationNotFoundError({ slug: input.integration });
3376 }
3377 const runtime = runtimes.get(integrationRow.plugin_id);
3378 const check = runtime?.plugin.checkHealth;
3379 if (!runtime || !check) return unknownHealth();
3380
3381 const values = yield* resolveInFlightValues(input);
3382 const record = rowToIntegrationRecord(
3383 integrationRow,
3384 describeAuthMethodsForRow(integrationRow),
3385 );
3386 const credential: ToolInvocationCredential = {
3387 owner: input.owner,
3388 integration: input.integration,
3389 // No connection exists yet (key-first); a synthetic name keeps the
3390 // credential shape whole. The probe authenticates on values+template,
3391 // not on this name (it only appears in upstream-error messages).
3392 connection: ConnectionName.make("(unsaved)"),
3393 template: input.template,
3394 value: values[PRIMARY_INPUT_VARIABLE] ?? null,
3395 values,
3396 config: record.config,
3397 };
3398 // Caller override (editor preview) wins; otherwise the declared spec
3399 // from the integration row. Nothing persists here: validate is the
3400 // key-first flow's dry run.
3401 const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined;
3402 const result = yield* foldPluginFailure(
3403 check({ ctx: runtime.ctx, integration: record, credential, spec }),
3404 `Validating credential for "${input.integration}" failed.`,
3405 );
3406 // Nothing persists here BY DESIGN, which makes this span the only
3407 // possible record of "what fraction of pasted credentials are rejected
3408 // at the door" — a signal the DB can never carry.
3409 yield* Effect.annotateCurrentSpan({
3410 "executor.health.status": result.status,
3411 ...(result.httpStatus !== undefined
3412 ? { "executor.health.http_status": result.httpStatus }
3413 : {}),
3414 });
3415 return result;
3416 }).pipe(
3417 Effect.withSpan("executor.connection.validate", {
3418 attributes: {
3419 "executor.tenant": tenant,
3420 ...(subject != null ? { "executor.subject": subject } : {}),
3421 "executor.integration": String(input.integration),
3422 },
3423 }),
3424 );
3425
3426 // 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