SQ 7.9LTS: Couldn't find root component with uuid XYZ

  • which versions are you using: 7.9.2LTS
  • what are you trying to achieve: delete several projects via Web-API
  • what have you tried so far to achieve this: see below

Hi,

I tried to clean up our SQ database and delete unused projects. Therefore I curated a list of project keys of about 700 projects to send those keys via a Python script to the API. Generally this works fine, but for a small amount of about 20 projects I got this error message:

{
    "errors": [
        {
            "msg": "Couldn't find root component with uuid <UUID>"
        }
    ]
}

The project isn’t visible in the web interface, but I can still see entries in several project_* and projects table/s. Restarting the server does not help. As soon as I send the deletion for the project key again to the API the same error message appears.

Well, I’m currently out of ideas. I could start deleting things in the database looking for the mentioned UUID, but don’t know, if this might help or if it may be a good idea. :slight_smile:

Any ideas or hints what I could try else?

Many thanks in advance! Regards, Thomas

Hi Thomas,

Generally, you should treat the database as a black box.

Could you share how you got those keys?

 
Ann

Hi Ann,

with blackbox you mean that the database is more or less tracking all projects, even though they are in deleted state? I’m not sure, what you exactly you mean with blackbox.

I used two Python scripts. The first script listed all available projects and searched the response from the API for a specific pattern in the links field. Finally I dumped the so generated dataframe into a SQLite database.

The second script loaded the SQLite database again into a dataframe and filtered the output for either no analysis date or for last analysis happened before a specific date. This output was then dumped into an Excel Sheet.

The generated information had the uuid, project key and other fields like last analysis as result. Deletion was done by just extracting the project key and was then piped into httpie for deletion via API.

Yes, it sounds a bit complicated, but we had to choose this approach because we had to inquire the need of those projects in the first step. And in the links field we had the the address holding also the information of the repository, which means in our case, we have a correlation to specific project teams.

Regards, Thomas

Hi,

About this :

Could you please send us the WS query that you’re using to get these projects ?
Maybe you’re getting other components that projects, that would explain your issue.

About this :

SonarQube is not compatible with SQLite db, I’m not sure to understand what you’re doing.

Moreover, what prevent you to do another WS queries to get the info that you need ?

Hi,

you didn’t get me right. The SQLite database I used wasn’t for SQ, it was rather for data analysis off SQ just to clarify for me which projects I can add to me deletion list. :slight_smile:

The way:

Python search request
 v 
Sonarqube API
 v
store data to Pandas Dataframe
 v
store output to SQLite DB
 v 
Python Analysis
 v
List with project keys
 v 
Python API call to Sonarqube (delete one by one)

So, Sonarqube was only involved twice, first when calling the API to get the data, second time to use the curated list of project keys. Only search and delete action was called, nothing done in the database directly.

Regards, Thomas

I think I’m getting closer to the problem. It seems that even though the root object exists, it can’t be found. The error message displayed when trying to delete this project can be found in sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java (tag 7.9.2). Unfortunately I’m not familiar with Java, so I’ve chosen to put the web component in TRACE mode and luckily I found a hint.

When trying to delete a project through the API, these queries are executed (seen in web.log):

sql=select pb.uuid as uuid, pb.project_uuid as projectUuid, pb.kee as kee, pb.key_type as keyType, pb.branch_type as branchType, pb.merge_branch_uuid as mergeBranchUuid, pb.pull_request_binary as pullRequestBinary, pb.manual_baseline_analysis_uuid as manualBaseline from project_branches pb where pb.project_uuid = ? | params=<id_mentioned_in_error_message>

sql=select p.id, p.uuid from projects p where ( p.project_uuid=? and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC') ) or ( uuid=? and p.scope = 'PRJ' and p.qualifier in ('APP', 'VW','TRK') ) | params=<id_mentioned_in_error_message>, <id_mentioned_in_error_message>

More interesting seems to be query #2 and there the second part after or. I tried it directly with a database client with two different project_uuids and - surprisingly or not - I got different results. While a current existing project prints out the information as desired, the problematic ID shows nothing. Example:
Query attempt 1:

select
	p.id,
	p.uuid,
	p.root_uuid,
	p.project_uuid 
from
	projects p
where
        ( project_uuid = 'AV2DeHkG5_gkRVehjwZ-'
	and p.scope = 'PRJ'
	and p.qualifier in ('APP', 'VW', 'TRK') ) 

Output:

id   |uuid                |root_uuid           |project_uuid        |
-----|--------------------|--------------------|--------------------|
43616|AV2DeHkG5_gkRVehjwZ-|AV2DeHkG5_gkRVehjwZ-|AV2DeHkG5_gkRVehjwZ-|

Query attempt #2:

select
	p.id,
	p.uuid,
	p.root_uuid,
	p.project_uuid 
from
	projects p
where
	( uuid = 'AV2DeHkG5_gkRVehjwZ-'
	and p.scope = 'PRJ'
	and p.qualifier in ('APP', 'VW', 'TRK') ) 

Output:

id|uuid|root_uuid|project_uuid|
--|----|---------|------------|

The only thing between those two statements is that in the second attempt I just deleted project_ and left uuid over. The string I search for is untouched.

The same here for a valid project with a different ID:

select
	p.id,
	p.uuid,
	p.root_uuid,
	p.project_uuid 
from
	projects p
where
	( project_uuid = 'AV2DeLbF5_gkRVehkCsj'
	and p.scope = 'PRJ'
	and p.qualifier in ('APP', 'VW', 'TRK') ) 
id    |uuid                |root_uuid           |project_uuid        |
------|--------------------|--------------------|--------------------|
324028|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|
select
	p.id,
	p.uuid,
	p.root_uuid,
	p.project_uuid 
from
	projects p
where
	( uuid = 'AV2DeLbF5_gkRVehkCsj'
	and p.scope = 'PRJ'
	and p.qualifier in ('APP', 'VW', 'TRK') ) 
id    |uuid                |root_uuid           |project_uuid        |
------|--------------------|--------------------|--------------------|
324028|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|

Conclusion is that the deletion process can’t find the desired root object even though it’s in the database. The problematic ID can be found with the project_uuid, but not with the uuid, even though both strings are the same.

Next step is to find out what’s going on with the column. Maybe it’s an issue with character encoding or problems with characters like hyphen.

Regards, Thomas