@@ -135,6 +135,44 @@ def log_object_path(full_name, job_id):
135135 return f"log/{ full_name } /{ job_id } "
136136
137137
138+ def classifier_payload (full_name , job_id ):
139+ """An API Gateway HTTP API v2.0 request, which is what lambda_http parses.
140+
141+ log_classifier is built on lambda_http with only the `apigw_http` feature, so
142+ it expects this envelope even on a direct invoke. Verified against the
143+ deployed function: a payload with no `job_id` returns its 400 "no job id
144+ provided" branch, and a non-numeric one fails in its `parse::<usize>()`,
145+ which together show both the envelope and the query string are read.
146+ """
147+ return {
148+ "version" : "2.0" ,
149+ "routeKey" : "$default" ,
150+ "rawPath" : "/" ,
151+ "rawQueryString" : f"job_id={ job_id } &repo={ full_name } " ,
152+ "headers" : {},
153+ "queryStringParameters" : {"job_id" : str (job_id ), "repo" : full_name },
154+ "requestContext" : {
155+ "accountId" : "308535385114" ,
156+ "apiId" : "gha-log-uploader" ,
157+ "domainName" : "lambda-invoke" ,
158+ "domainPrefix" : "lambda-invoke" ,
159+ "http" : {
160+ "method" : "GET" ,
161+ "path" : "/" ,
162+ "protocol" : "HTTP/1.1" ,
163+ "sourceIp" : "127.0.0.1" ,
164+ "userAgent" : "gha-log-uploader" ,
165+ },
166+ "requestId" : f"gha-log-uploader-{ job_id } " ,
167+ "routeKey" : "$default" ,
168+ "stage" : "$default" ,
169+ "time" : "01/Jan/1970:00:00:00 +0000" ,
170+ "timeEpoch" : 0 ,
171+ },
172+ "isBase64Encoded" : False ,
173+ }
174+
175+
138176def classify_log (full_name , job_id ):
139177 """Kick off classification for a log we just stored. Returns True on handoff.
140178
@@ -149,7 +187,7 @@ def classify_log(full_name, job_id):
149187 lambda_client .invoke (
150188 FunctionName = LOG_CLASSIFIER_FUNCTION ,
151189 InvocationType = "Event" ,
152- Payload = json .dumps ({ "job_id" : job_id , "repo" : full_name } ).encode (),
190+ Payload = json .dumps (classifier_payload ( full_name , job_id ) ).encode (),
153191 )
154192 return True
155193 except Exception as err :
0 commit comments