@@ -408,12 +408,13 @@ targets:
408408 ) . toBe ( true ) ;
409409 } ) ;
410410
411- it ( 'accepts env-templated use_target values without resolving the env during validation ' , async ( ) => {
411+ it ( 'rejects use_target on authored target definitions ' , async ( ) => {
412412 const filePath = path . join ( tempDir , 'templated-use-target.yaml' ) ;
413413 await writeFile (
414414 filePath ,
415415 `targets:
416416 - id: default
417+ provider: mock
417418 use_target: "{{ env.AGENT_TARGET }}"
418419 - id: grader
419420 use_target: "{{ env.GRADER_TARGET }}"
@@ -424,34 +425,23 @@ targets:
424425` ,
425426 ) ;
426427
427- const originalAgentTarget = process . env . AGENT_TARGET ;
428- const originalGraderTarget = process . env . GRADER_TARGET ;
429- Reflect . deleteProperty ( process . env , 'AGENT_TARGET' ) ;
430- Reflect . deleteProperty ( process . env , 'GRADER_TARGET' ) ;
431-
432- try {
433- const result = await validateTargetsFile ( filePath ) ;
428+ const result = await validateTargetsFile ( filePath ) ;
434429
435- expect ( result . valid ) . toBe ( true ) ;
436- expect (
437- result . errors . some (
438- ( error ) =>
439- error . severity === 'error' &&
440- error . message . includes ( "Missing or invalid 'provider' field" ) ,
441- ) ,
442- ) . toBe ( false ) ;
443- } finally {
444- if ( originalAgentTarget === undefined ) {
445- Reflect . deleteProperty ( process . env , 'AGENT_TARGET' ) ;
446- } else {
447- process . env . AGENT_TARGET = originalAgentTarget ;
448- }
449- if ( originalGraderTarget === undefined ) {
450- Reflect . deleteProperty ( process . env , 'GRADER_TARGET' ) ;
451- } else {
452- process . env . GRADER_TARGET = originalGraderTarget ;
453- }
454- }
430+ expect ( result . valid ) . toBe ( false ) ;
431+ expect ( result . errors ) . toContainEqual (
432+ expect . objectContaining ( {
433+ severity : 'error' ,
434+ location : 'targets[0].use_target' ,
435+ message : expect . stringContaining ( "'use_target' field has been removed" ) ,
436+ } ) ,
437+ ) ;
438+ expect ( result . errors ) . toContainEqual (
439+ expect . objectContaining ( {
440+ severity : 'error' ,
441+ location : 'targets[1].use_target' ,
442+ message : expect . stringContaining ( "'use_target' field has been removed" ) ,
443+ } ) ,
444+ ) ;
455445 } ) ;
456446
457447 it ( 'rejects legacy env interpolation in target YAML' , async ( ) => {
0 commit comments