File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
packages/aws-cdk-lib/core Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ export class Tag extends TagBase {
121121 constructor ( key : string , value : string , props : TagProps = { } ) {
122122 super ( key , props ) ;
123123 if ( value === undefined ) {
124- throw new UnscopedValidationError ( ' Tag must have a value' ) ;
124+ throw new UnscopedValidationError ( ` Tag ' ${ key } ' must have a value` ) ;
125125 }
126126 this . value = value ;
127127 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 ITaggable ,
1414 ITaggableV2 ,
1515 AspectPriority ,
16+ UnscopedValidationError ,
1617} from '../lib' ;
1718import { synthesize } from '../lib/private/synthesis' ;
1819
@@ -331,4 +332,14 @@ describe('tag aspect', () => {
331332 } ) . toThrow ( ) ;
332333 } ) ;
333334 } ) ;
335+
336+ test ( 'if tag value is undefined, it raises with appropriate content' , ( ) => {
337+ expect ( ( ) => {
338+ new Tag ( 'test-key' , undefined as any ) ;
339+ } ) . toThrow ( UnscopedValidationError ) ;
340+
341+ expect ( ( ) => {
342+ new Tag ( 'test-key' , undefined as any ) ;
343+ } ) . toThrow ( "Tag 'test-key' must have a value" ) ;
344+ } ) ;
334345} ) ;
You can’t perform that action at this time.
0 commit comments