Skip to content

Commit 34f14f7

Browse files
committed
fix: address CR feedback — scopes optional, specific validation errors
1 parent 5a3c348 commit 34f14f7

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

src/schema/schemas/agentcore-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const OAuthCredentialSchema = z.object({
9696
/** OIDC discovery URL for the OAuth provider */
9797
discoveryUrl: z.string().url(),
9898
/** Scopes this credential provider supports */
99-
scopes: z.array(z.string()).default([]),
99+
scopes: z.array(z.string()).optional(),
100100
/** Credential provider vendor type */
101101
vendor: z.string().default('CustomOauth2'),
102102
/** Whether this credential was auto-created by the CLI (e.g., for CUSTOM_JWT inbound auth) */

src/schema/schemas/mcp.ts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

312319
export type AgentCoreGatewayTarget = z.infer<typeof AgentCoreGatewayTargetSchema>;
313320

0 commit comments

Comments
 (0)