diff --git a/packages/project-management-automation/lib/tasks/add-milestone/index.js b/packages/project-management-automation/lib/tasks/add-milestone/index.js index 1058f6bc9d7a71..f70a6560bea996 100644 --- a/packages/project-management-automation/lib/tasks/add-milestone/index.js +++ b/packages/project-management-automation/lib/tasks/add-milestone/index.js @@ -27,8 +27,10 @@ const isDuplicateValidationError = ( requestError ) => { // The included version of RequestError provides no way to access the // full 'errors' array that the github REST API returns. Hopefully they // resolve this soon! - const errorMessage = /** @type {undefined | null | {message?: string}} */ ( requestError ) - ?.message; + const errorMessage = + requestError && + typeof requestError === 'object' && + /** @type {{message?: string}} */ ( requestError ).message; return ( typeof errorMessage === 'string' && errorMessage.includes( 'already_exists' )