shijl0925 / python-sonarqube-api

Python Client library for interacting with Community, Developer, and Enterprise Editions SonarQube's REST APIs and SonarCloud's REST APIs.
https://python-sonarqube-pro-api.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
133 stars 76 forks source link

Error in request. Possibly Not Found error [404]: Component 'XXXX' on branch 'master' not found #78

Closed xuri422 closed 1 year ago

xuri422 commented 1 year ago

def get_sonarqube_info(self, branch="master", component=None, url=None, username=None, password=None): try: sonar = SonarQubeClient(sonarqube_url=url) sonar.auth.authenticate_user(login=username, password=password) _component_data = sonar.measures.get_component_with_specifiedmeasures( component=component, branch=branch, metricKeys=METRICKEYS ) ........

In this code lien, have a except as: Error in request. Possibly Not Found error [404]: Component 'XXXX' on branch 'master' not found

but in another project ,this code can run normally. the XXXX project is the first scan. In sonarquebe server, [MEASURES]-->[new code ] show result as: Measures on New Code will appear after the second analysis of this branch.

So, how can I revole it?

shijl0925 commented 1 year ago

I tested my project, which is scanned for the first time, I didn't find the problem you described.

xuri422 commented 1 year ago

Error in request. Possibly Not Found error [404]: Component 'XXXXX' on branch 'master' not found Traceback (most recent call last): File "G:\PycharmProjects\test1\AutoCodeScan.py", line 609, in execute_scan SonarqubeManager().main(project_name, project_ver, emailaddr) File "G:\PycharmProjects\test1\sendmail.py", line 411, in main sonarqube_data = self.get_sonarqube_info(branch=SonarqubeConfig["branch"], File "G:\PycharmProjects\test1\sendmail.py", line 225, in get_sonarqube_info component_data = sonar.measures.get_component_with_specified_measures( File "C:\Python3\lib\site-packages\sonarqube\utils\common.py", line 132, in inner_func response = self._get(url_pattern, params=params) File "C:\Python3\lib\site-packages\sonarqube\utils\rest_client.py", line 141, in _get return self.request("GET", path=path, params=params, data=data, headers=headers) File "C:\Python3\lib\site-packages\sonarqube\utils\rest_client.py", line 99, in request raise NotFoundError(msg) sonarqube.utils.exceptions.NotFoundError: Error in request. Possibly Not Found error [404]: Component 'XXXXXX' on branch 'master' not found

This is the error message. I found it in many project scanned.