Problem
GC sits at 2024-12.960.0 and the quality.evaluation.completed webhook keeps hitting the Express listener with a broken result array. JWT validation passes instantly, but the middleware doesn’t handle the shifted nesting and throws a TypeError: Cannot read properties of undefined (reading 'score').
{ "criteria": null, "scoring": undefined }
The result array structure in quality.evaluation.completed is notoriously unstable between platform releases. Don’t trust the static schema docs blindly. The error usually happens because the payload flattens when there’s only one criterion, or nests deeper if there are multiple. You’re hitting the undefined branch because the parser expects an array but gets an object, or vice versa.
Add a safety check before accessing properties. Here’s a quick Express middleware snippet to normalize it:
app.use('/webhook/quality', (req, res) => {
const payload = req.body;
const criteria = payload.result?.criteria || [];
// Normalize to array if it's a single object
const normalizedCriteria = Array.isArray(criteria) ? criteria : [criteria];
const scores = normalizedCriteria.map(c => c.score);
console.log('Scores:', scores);
res.status(200).send('OK');
});
Check the raw body in your logs. If result is null, the evaluation might still be processing asynchronously. The webhook fires early sometimes. Add a retry policy in the GC webhook config to catch late arrivals.