Skip to content

fix(uta): export utaConfigSchema from uta-protocol — unbreaks test-connection#209

Open
iridite wants to merge 1 commit into
TraderAlice:masterfrom
iridite:fix/uta-test-connection-schema
Open

fix(uta): export utaConfigSchema from uta-protocol — unbreaks test-connection#209
iridite wants to merge 1 commit into
TraderAlice:masterfrom
iridite:fix/uta-test-connection-schema

Conversation

@iridite
Copy link
Copy Markdown

@iridite iridite commented May 25, 2026

Summary

Fixes a runtime TypeError that crashes the UTA service when testing any exchange connection (observed on Bitget, affects all presets):

Cannot read properties of undefined (reading 'parse')

Root Cause

services/uta/src/http/routes-trading.ts:191 imports utaConfigSchema from @traderalice/uta-protocol:

const { utaConfigSchema } = await import('@traderalice/uta-protocol')
const utaConfig = utaConfigSchema.parse({ ...body, id: body.id ?? '__test__' })

But packages/uta-protocol/src/schemas/index.ts was empty (export {}). The destructured utaConfigSchema is undefined, and .parse() on undefined throws.

Fix

  • Add utaConfigSchema + guardConfigSchema to packages/uta-protocol/src/schemas/index.ts (the canonical location the UTA service already expects)
  • Replace the duplicate definition in src/core/config.ts with a re-export from the protocol package, keeping the existing public API intact

Test plan

  • tsc --noEmit clean
  • Create a new UTA with any exchange preset → "Test Connection" no longer crashes with TypeError
  • Existing imports of utaConfigSchema from src/core/config.ts still resolve

🤖 Generated with Claude Code

…nnection

The UTA service's `/test-connection` endpoint (routes-trading.ts:191)
imports `utaConfigSchema` from `@traderalice/uta-protocol`, but the
schema was only defined in Alice's `src/core/config.ts` and never
exported from the protocol package. This caused a TypeError:

  Cannot read properties of undefined (reading 'parse')

…on every "Test <exchange>" action in the New UTA flow (affects all
exchanges, not just Bitget).

Fix: define `utaConfigSchema` + `guardConfigSchema` in the protocol
package (`packages/uta-protocol/src/schemas/index.ts`) and re-export
from `src/core/config.ts` to keep the existing public API intact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 02:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Moves the Unified Trading Account (UTA) config schema/type out of src/core/config.ts into the shared uta-protocol package so both server and clients can depend on one canonical definition.

Changes:

  • Replaced the local utaConfigSchema definition with an import from @traderalice/uta-protocol.
  • Added utaConfigSchema and UTAConfig to packages/uta-protocol/src/schemas/index.ts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/core/config.ts Removes in-repo UTA schema/type and re-exports the shared protocol schema/type.
packages/uta-protocol/src/schemas/index.ts Introduces the canonical UTA schema/type in the protocol package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/config.ts
Comment on lines +318 to +319
import { utaConfigSchema, type UTAConfig } from '@traderalice/uta-protocol'
export { utaConfigSchema, UTAConfig }
Comment thread src/core/config.ts
path: ['ephemeral'],
})
import { utaConfigSchema, type UTAConfig } from '@traderalice/uta-protocol'
export { utaConfigSchema, UTAConfig }
Comment on lines +17 to +28
export const utaConfigSchema = z.object({
id: z.string(),
label: z.string().optional(),
presetId: z.string(),
enabled: z.boolean().default(true),
guards: z.array(guardConfigSchema).default([]),
presetConfig: z.record(z.string(), z.unknown()).default({}),
ephemeral: z.boolean().optional(),
}).refine((u) => u.ephemeral !== true || u.presetId === 'mock-simulator', {
message: 'ephemeral: true is only allowed on mock-simulator UTAs (would destroy real broker history at next boot)',
path: ['ephemeral'],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants