SonarCloud Azure DevOps PR Analysis fails with a 404 error

The Problem

Recently had an issue on a project that had been paused for a few months.

When we restarted the project we found that the SonarCloud PR analysis, running via an Azure DevOps YAML pipeline, was failing with a 404 error. The strange thing was that the same pipeline running analysis of the main trunk or the branch the PR related to worked without error.

The Solution

The issue was fixed by regenerating the SonarCloud PAT that was registered in the Azure DevOps project's Service Connection.

For good measure we also replaced the Azure DevOps PAT registered in SonarCloud to allow it to decorate the Azure DevOps PRs.

We don't think either PAT had expired, as they worked for the main and branch SonarCloud analysis, so no idea why this worked. But it did, and that is the important thing.