MCPcopy
hub / github.com/google/clusterfuzz / post

Method post

src/appengine/handlers/external_update.py:139–178  ·  view source on GitHub ↗

Handle a post request.

(self, message)

Source from the content-addressed store, hash-verified

137
138 @handler.pubsub_push
139 def post(self, message):
140 """Handle a post request."""
141 testcase_id = message.attributes.get('testcaseId')
142 if not testcase_id:
143 raise helpers.EarlyExitError('Missing testcaseId.', 400)
144
145 revision = message.attributes.get('revision')
146 if not revision or not revision.isdigit():
147 raise helpers.EarlyExitError('Missing revision.', 400)
148
149 revision = int(revision)
150 testcase = data_handler.get_testcase_by_id(testcase_id)
151 job = data_types.Job.query(data_types.Job.name == testcase.job_type).get()
152 if not job or not job.is_external():
153 raise helpers.EarlyExitError('Invalid job.', 400)
154
155 if message.data:
156 stacktrace = message.data.decode()
157 else:
158 logs.info(f'No stacktrace provided (testcase_id={testcase_id}).')
159 stacktrace = ''
160
161 protocol_version = message.attributes.get('protocolVersion', OLD_PROTOCOL)
162 if protocol_version == OLD_PROTOCOL:
163 # Old: stacktrace is a str.
164 stacktraces = [stacktrace]
165 logs.info(f'Old format stacktrace string provided '
166 f'(testcase_id={testcase_id}).')
167 elif protocol_version == NEW_PROTOCOL:
168 # New: stacktrace is a JSON array.
169 stacktraces = json.loads(stacktrace)
170 logs.info(f'New format stacktrace JSON list provided '
171 f'(testcase_id={testcase_id}).')
172 else:
173 # Invalid: stacktrace is presumably ill-formed.
174 stacktraces = []
175
176 error = message.attributes.get('error')
177 handle_update(testcase, revision, stacktraces, error, protocol_version)
178 return 'OK'

Callers

nothing calls this directly

Calls 4

handle_updateFunction · 0.85
queryMethod · 0.80
is_externalMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected