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

Function connectionValidate

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

Source from the content-addressed store, hash-verified

3284 );
3285
3286 const connectionValidate = (
3287 input: ValidateConnectionInput,
3288 ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> =>
3289 Effect.gen(function* () {
3290 const integrationRow = yield* findIntegrationRow(input.integration);
3291 if (!integrationRow) {
3292 return yield* new IntegrationNotFoundError({ slug: input.integration });
3293 }
3294 const runtime = runtimes.get(integrationRow.plugin_id);
3295 const check = runtime?.plugin.checkHealth;
3296 if (!runtime || !check) return unknownHealth();
3297
3298 const values = yield* resolveInFlightValues(input);
3299 const record = rowToIntegrationRecord(
3300 integrationRow,
3301 describeAuthMethodsForRow(integrationRow),
3302 );
3303 const credential: ToolInvocationCredential = {
3304 owner: input.owner,
3305 integration: input.integration,
3306 // No connection exists yet (key-first); a synthetic name keeps the
3307 // credential shape whole. The probe authenticates on values+template,
3308 // not on this name (it only appears in upstream-error messages).
3309 connection: ConnectionName.make("(unsaved)"),
3310 template: input.template,
3311 value: values[PRIMARY_INPUT_VARIABLE] ?? null,
3312 values,
3313 config: record.config,
3314 };
3315 // Caller override (editor preview) wins; otherwise the declared spec
3316 // from the integration row. Nothing persists here: validate is the
3317 // key-first flow's dry run.
3318 const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined;
3319 const result = yield* foldPluginFailure(
3320 check({ ctx: runtime.ctx, integration: record, credential, spec }),
3321 `Validating credential for "${input.integration}" failed.`,
3322 );
3323 // Nothing persists here BY DESIGN, which makes this span the only
3324 // possible record of "what fraction of pasted credentials are rejected
3325 // at the door" — a signal the DB can never carry.
3326 yield* Effect.annotateCurrentSpan({
3327 "executor.health.status": result.status,
3328 ...(result.httpStatus !== undefined
3329 ? { "executor.health.http_status": result.httpStatus }
3330 : {}),
3331 });
3332 return result;
3333 }).pipe(
3334 Effect.withSpan("executor.connection.validate", {
3335 attributes: { "executor.integration": String(input.integration) },
3336 }),
3337 );
3338
3339 // Clear the sync stamp so the next tools read re-produces this connection's
3340 // catalog. The deferred variant of `connectionsRefresh` for signals that

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