okorach / sonar-tools

Additional command line based tools to help in SonarQube administration tasks
GNU Lesser General Public License v3.0
47 stars 18 forks source link

sonar-config projects : Project key 'xxxx:xxxx.xxxx' not found #1509

Open Jay-jakwak4 opened 1 week ago

Jay-jakwak4 commented 1 week ago

Hi Team

If there is no project when importing sonar-config, an error occurs. If the project does not exist, is it possible to create a new one and import it?

2024-11-18 18:15:58,176 | sonar-config | INFO    | MainThread      | Importing project key 'xxxx:xxxx.xxxx'
2024-11-18 18:15:58,283 | sonar-config | ERROR   | MainThread      | Project key 'xxxx:xxxx.xxxx' not found
2024-11-18 18:16:08,353 | sonar-config | ERROR   | MainThread      | HTTPSConnectionPool(host='sonarqube-secondary.xxx.net', port=443): Read timed out. (read timeout=10) while
2024-11-18 18:16:08,353 | sonar-config | ERROR   | MainThread      | HTTPSConnectionPool(host='sonarqube-secondary.xxx.net', port=443): Read timed out. (read timeout=10) while creating project 'xxx:xxx.xxx'
Traceback (most recent call last):
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/projects.py", line 1604, in import_config
    o = Project.get_object(endpoint, key)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/projects.py", line 170, in get_object
    raise exceptions.ObjectNotFound(key, f"Project key '{key}' not found")
sonar.exceptions.ObjectNotFound: ERROR 5: Project key 'xxx:xxx.xxx' not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 536, in _make_request
    response = conn.getresponse()
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connection.py", line 507, in getresponse
    httplib_response = super().getresponse()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1349, in getresponse
    response.begin()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 277, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 843, in urlopen
    retries = retries.increment(
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/util/retry.py", line 474, in increment
    raise reraise(type(error), error, _stacktrace)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/util/util.py", line 39, in reraise
    raise value
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 789, in urlopen
    response = self._make_request(
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 538, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/urllib3/connectionpool.py", line 369, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='sonarqube-secondary.xxx.net', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jakwak4/Library/Python/3.9/bin/sonar-config", line 8, in <module>
    sys.exit(main())
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/cli/config.py", line 283, in main
    __import_config(endpoint, what, **kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/cli/config.py", line 250, in __import_config
    func(endpoint, data, key_list=key_list)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/projects.py", line 1607, in import_config
    o = Project.create(endpoint, key, data["name"])
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/projects.py", line 209, in create
    util.handle_error(e, f"creating project '{key}'", catch_http_errors=(HTTPStatus.BAD_REQUEST,))
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/utilities.py", line 491, in handle_error
    raise e
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/projects.py", line 207, in create
    endpoint.post(_CREATE_API, params={"project": key, "name": name})
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/platform.py", line 213, in post
    return self.__run_request(requests.post, api, params, data, mute, **kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/platform.py", line 298, in __run_request
    util.handle_error(e, "")
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/utilities.py", line 491, in handle_error
    raise e
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/sonar/platform.py", line 279, in __run_request
    r = request(
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/jakwak4/Library/Python/3.9/lib/python/site-packages/requests/adapters.py", line 713, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='sonarqube-secondary.xxx.net', port=443): Read timed out. (read timeout=10)
❯

sonar-tools version : 3.6

Thanks

okorach commented 4 days ago

Hi @Jay-jakwak4,

Project creation on the fly is a bit touchy and requires significant work to do it well. This will be added in a future release

Jay-jakwak4 commented 2 days ago

Hi @okorach If so, is it possible to treat this as a warning and move forward until future release? The import could not complete because sonar-config was terminated. Thanks