File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -158,10 +158,34 @@ export function isEcrRegistry(registryHost: string) {
158158}
159159
160160function parseRegistryTags ( tags : string ) : Tag [ ] {
161- return tags . split ( "," ) . map ( ( tag ) => {
162- const [ key , value ] = tag . split ( "=" ) ;
163- return { Key : key , Value : value } ;
164- } ) ;
161+ if ( ! tags ) {
162+ return [ ] ;
163+ }
164+
165+ return tags
166+ . split ( "," )
167+ . map ( ( t ) => {
168+ const tag = t . trim ( ) ;
169+ if ( tag . length === 0 ) {
170+ return null ;
171+ }
172+
173+ // If there's no '=' in the tag, treat the whole tag as the key with an empty value
174+ const equalIndex = tag . indexOf ( "=" ) ;
175+ const key = equalIndex === - 1 ? tag : tag . slice ( 0 , equalIndex ) ;
176+ const value = equalIndex === - 1 ? "" : tag . slice ( equalIndex + 1 ) ;
177+
178+ if ( key . trim ( ) . length === 0 ) {
179+ logger . warn ( "Invalid ECR tag format (empty key), skipping tag" , { tag : t } ) ;
180+ return null ;
181+ }
182+
183+ return {
184+ Key : key . trim ( ) ,
185+ Value : value . trim ( ) ,
186+ } as Tag ;
187+ } )
188+ . filter ( ( tag ) : tag is Tag => tag !== null ) ;
165189}
166190
167191async function createEcrRepository ( {
You can’t perform that action at this time.
0 commit comments