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

Function connectionValidate

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

Source from the content-addressed store, hash-verified

3795 );
3796
3797 const connectionValidate = (
3798 input: ValidateConnectionInput,
3799 ): Effect.Effect<HealthCheckResult, IntegrationNotFoundError | StorageFailure> =>
3800 Effect.gen(function* () {
3801 const integrationRow = yield* findIntegrationRow(input.integration);
3802 if (!integrationRow) {
3803 return yield* new IntegrationNotFoundError({ slug: input.integration });
3804 }
3805 const runtime = runtimes.get(integrationRow.plugin_id);
3806 const check = runtime?.plugin.checkHealth;
3807 if (!runtime || !check) return unknownHealth();
3808
3809 const values = yield* resolveInFlightValues(input);
3810 const record = rowToIntegrationRecord(
3811 integrationRow,
3812 describeAuthMethodsForRow(integrationRow),
3813 );
3814 const credential: ToolInvocationCredential = {
3815 owner: input.owner,
3816 integration: input.integration,
3817 // No connection exists yet (key-first); a synthetic name keeps the
3818 // credential shape whole. The probe authenticates on values+template,
3819 // not on this name (it only appears in upstream-error messages).
3820 connection: ConnectionName.make("(unsaved)"),
3821 template: input.template,
3822 value: values[PRIMARY_INPUT_VARIABLE] ?? null,
3823 values,
3824 config: record.config,
3825 };
3826 // Caller override (editor preview) wins; otherwise the declared spec
3827 // from the integration row. Nothing persists here: validate is the
3828 // key-first flow's dry run.
3829 const spec = input.spec ?? describeHealthCheckForRow(integrationRow) ?? undefined;
3830 const result = yield* foldPluginFailure(
3831 check({ ctx: runtime.ctx, integration: record, credential, spec }),
3832 `Validating credential for "${input.integration}" failed.`,
3833 );
3834 // Nothing persists here BY DESIGN, which makes this span the only
3835 // possible record of "what fraction of pasted credentials are rejected
3836 // at the door" — a signal the DB can never carry.
3837 yield* Effect.annotateCurrentSpan({
3838 "executor.health.status": result.status,
3839 ...(result.httpStatus !== undefined
3840 ? { "executor.health.http_status": result.httpStatus }
3841 : {}),
3842 });
3843 return result;
3844 }).pipe(
3845 Effect.withSpan("executor.connection.validate", {
3846 attributes: {
3847 "executor.tenant": tenant,
3848 ...(subject != null ? { "executor.subject": subject } : {}),
3849 "executor.integration": String(input.integration),
3850 },
3851 }),
3852 );
3853
3854 // 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