@@ -286,28 +286,35 @@ export const AgentCoreGatewayTargetSchema = z
286286 outboundAuth : OutboundAuthSchema . optional ( ) ,
287287 } )
288288 . strict ( )
289- . refine (
290- data => {
291- // External MCP Server: needs endpoint, no compute
292- if ( data . targetType === 'mcpServer' && ! data . compute && ! data . endpoint ) {
293- return false ;
294- }
295- // Lambda target: needs compute and tool definitions
296- if ( data . targetType === 'lambda' ) {
297- if ( ! data . compute ) return false ;
298- if ( ! data . toolDefinitions || data . toolDefinitions . length === 0 ) return false ;
299- }
300- // Outbound auth with credential needs a credential name
301- if ( data . outboundAuth && data . outboundAuth . type !== 'NONE' && ! data . outboundAuth . credentialName ) {
302- return false ;
303- }
304- return true ;
305- } ,
306- {
307- message :
308- 'Invalid target configuration. MCP Server targets need an endpoint or compute. Lambda targets need compute and tool definitions. OAuth/API_KEY auth needs a credential name.' ,
289+ . superRefine ( ( data , ctx ) => {
290+ if ( data . targetType === 'mcpServer' && ! data . compute && ! data . endpoint ) {
291+ ctx . addIssue ( {
292+ code : z . ZodIssueCode . custom ,
293+ message : 'MCP Server targets require either an endpoint URL or compute configuration.' ,
294+ } ) ;
309295 }
310- ) ;
296+ if ( data . targetType === 'lambda' && ! data . compute ) {
297+ ctx . addIssue ( {
298+ code : z . ZodIssueCode . custom ,
299+ message : 'Lambda targets require compute configuration.' ,
300+ path : [ 'compute' ] ,
301+ } ) ;
302+ }
303+ if ( data . targetType === 'lambda' && ( ! data . toolDefinitions || data . toolDefinitions . length === 0 ) ) {
304+ ctx . addIssue ( {
305+ code : z . ZodIssueCode . custom ,
306+ message : 'Lambda targets require at least one tool definition.' ,
307+ path : [ 'toolDefinitions' ] ,
308+ } ) ;
309+ }
310+ if ( data . outboundAuth && data . outboundAuth . type !== 'NONE' && ! data . outboundAuth . credentialName ) {
311+ ctx . addIssue ( {
312+ code : z . ZodIssueCode . custom ,
313+ message : `${ data . outboundAuth . type } outbound auth requires a credentialName.` ,
314+ path : [ 'outboundAuth' , 'credentialName' ] ,
315+ } ) ;
316+ }
317+ } ) ;
311318
312319export type AgentCoreGatewayTarget = z . infer < typeof AgentCoreGatewayTargetSchema > ;
313320
0 commit comments