Skip to content

Commit b19efb3

Browse files
christsoclaude
andcommitted
fix(core): allow provider to be omitted when use_target is set
Updated both the Zod schema (BASE_TARGET_SCHEMA) and the targets validator to accept targets without a provider field when use_target handles delegation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 86727fa commit b19efb3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/core/src/evaluation/validation/targets-validator.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,19 @@ export async function validateTargetsFile(filePath: string): Promise<ValidationR
533533

534534
// Required field: provider
535535
const provider = target.provider;
536+
const hasUseTarget =
537+
typeof target.use_target === 'string' && target.use_target.trim().length > 0;
536538
const providerValue = typeof provider === 'string' ? provider.trim().toLowerCase() : undefined;
537539
const isTemplated = typeof provider === 'string' && /^\$\{\{.+\}\}$/.test(provider.trim());
538-
if (typeof provider !== 'string' || provider.trim().length === 0) {
540+
if (!hasUseTarget && (typeof provider !== 'string' || provider.trim().length === 0)) {
539541
errors.push({
540542
severity: 'error',
541543
filePath: absolutePath,
542544
location: `${location}.provider`,
543-
message: "Missing or invalid 'provider' field (must be a non-empty string)",
545+
message:
546+
"Missing or invalid 'provider' field (must be a non-empty string, or use use_target for delegation)",
544547
});
545-
} else if (!isTemplated && !knownProviders.includes(provider)) {
548+
} else if (typeof provider === 'string' && !isTemplated && !knownProviders.includes(provider)) {
546549
// Warning for unknown providers (non-fatal); skip when provider uses ${{ VAR }}
547550
errors.push({
548551
severity: 'warning',

0 commit comments

Comments
 (0)