@@ -88,6 +88,38 @@ function generateRunnerServiceConfig(githubRunnerConfig: CreateGitHubRunnerConfi
8888 return config ;
8989}
9090
91+ function parseSsmParameterStoreTags ( input ?: string ) {
92+ if ( ! input || input . trim ( ) === '' ) return [ ] as { Key : string ; Value : string } [ ] ;
93+
94+ try {
95+ const parsed = JSON . parse ( input ) ;
96+ if ( ! Array . isArray ( parsed ) ) {
97+ logger . warn ( 'SSM_PARAMETER_STORE_TAGS is not a JSON array; ignoring and using [].' ) ;
98+ return [ ] ;
99+ }
100+
101+ const isValid = parsed . every (
102+ ( item : any ) =>
103+ item &&
104+ typeof item === 'object' &&
105+ typeof item . Key === 'string' &&
106+ typeof item . Value === 'string' ,
107+ ) ;
108+
109+ if ( ! isValid ) {
110+ logger . warn (
111+ 'SSM_PARAMETER_STORE_TAGS must be an array of objects with string Key and Value properties; ignoring and using [].' ,
112+ ) ;
113+ return [ ] ;
114+ }
115+
116+ return parsed as { Key : string ; Value : string } [ ] ;
117+ } catch ( err ) {
118+ logger . warn ( 'SSM_PARAMETER_STORE_TAGS is not valid JSON; ignoring and using [].' , err as Error ) ;
119+ return [ ] ;
120+ }
121+ }
122+
91123async function getGithubRunnerRegistrationToken ( githubRunnerConfig : CreateGitHubRunnerConfig , ghClient : Octokit ) {
92124 const registrationToken =
93125 githubRunnerConfig . runnerType === 'Org'
@@ -255,10 +287,9 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage
255287 const onDemandFailoverOnError = process . env . ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS
256288 ? ( JSON . parse ( process . env . ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS ) as [ string ] )
257289 : [ ] ;
258- const ssmParameterStoreTags : { Key : string ; Value : string } [ ] =
259- process . env . SSM_PARAMETER_STORE_TAGS && process . env . SSM_PARAMETER_STORE_TAGS . trim ( ) !== ''
260- ? JSON . parse ( process . env . SSM_PARAMETER_STORE_TAGS )
261- : [ ] ;
290+ const ssmParameterStoreTags : { Key : string ; Value : string } [ ] = parseSsmParameterStoreTags (
291+ process . env . SSM_PARAMETER_STORE_TAGS ,
292+ ) ;
262293
263294 if ( ephemeralEnabled && payload . eventType !== 'workflow_job' ) {
264295 logger . warn ( `${ payload . eventType } event is not supported in combination with ephemeral runners.` ) ;
0 commit comments