Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: SHA could not be resolved #35

Open
Creadeyh opened this issue Apr 7, 2023 · 4 comments
Open

Error: SHA could not be resolved #35

Creadeyh opened this issue Apr 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Creadeyh
Copy link
Collaborator

Creadeyh commented Apr 7, 2023

When using the populate command on the Python project https://github.com/alievk/avatarify-python we get this error:

Traceback (most recent call last):
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\main.py", line 403, in
cli(obj={})
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 764, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\main.py", line 296, in populate
git.populate_db(skip_versions)
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\connectors\git.py", line 135, in populate_db
self.create_commits_from_repo()
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\utils\timeit.py", line 9, in timeit_wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\connectors\git.py", line 95, in create_commits_from_repo
dmm_unit_size=git_commit.dmm_unit_size,
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 797, in dmm_unit_size
return self._delta_maintainability(DMMProperty.UNIT_SIZE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 845, in _delta_maintainability
delta_profile = self._delta_risk_profile(dmm_prop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 863, in _delta_risk_profile
mod for mod in self.modified_files if mod.language_supported
^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 716, in modified_files
return self._parse_diff(diff_index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 728, in _parse_diff
"content": self._get_undecoded_content(diff.b_blob),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\pydriller\domain\commit.py", line 752, in _get_undecoded_content
return blob.data_stream.read() if blob is not None else None
^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\objects\base.py", line 142, in data_stream
return self.repo.odb.stream(self.binsha)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\db.py", line 45, in stream
hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(binsha))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1400, in stream_object_data
hexsha, typename, size = self.__get_object_header(cmd, ref)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1370, in __get_object_header
return self._parse_object_header(cmd.stdout.readline())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antoine.micard\Desktop\bugprediction repos\bugprediction\venv\Lib\site-packages\git\cmd.py", line 1331, in _parse_object_header
raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
ValueError: SHA b'72a32a67dee3a67dff76f565551907a2fc7e88e6' could not be resolved, git returned: b'72a32a67dee3a67dff76f565551907a2fc7e88e6 missing'

@Creadeyh Creadeyh added the bug Something isn't working label Apr 7, 2023
@Creadeyh
Copy link
Collaborator Author

Creadeyh commented Apr 7, 2023

Fixed the first issue in #36
The error was caused by a submodule commit within an avatarify commit (ex: commit) which couldn't be accessed by PyDriller when calculating the DMM metrics.
As these metrics are often returning NULL anyway, we are skipping them for that particular commit when the error is encountered

@Creadeyh
Copy link
Collaborator Author

Creadeyh commented Apr 7, 2023

Same error is raised when calculating the versions' churn.
Since we just call PyDriller's CodeChurn class on the whole version, we can't just skip the troublesome commits.
As stated in #36 the issue has been submitted on PyDriller's GitHub ishepard/pydriller#260 and I am waiting for a solution from them.

@Creadeyh
Copy link
Collaborator Author

Creadeyh commented Apr 14, 2023

Same error is raised when calling pydriller.Commit.modified_files

@Creadeyh
Copy link
Collaborator Author

While waiting for a fix from PyDriller, BugPrediction will just skip the problematic commits/versions and leave a warning log. This issue with submodules will also be added in the readme's limitations

@Creadeyh Creadeyh mentioned this issue Apr 14, 2023
MelisandeDes pushed a commit that referenced this issue Apr 18, 2023
* Fixed issue in git connector

The issue is caused by a submodule commit that cannot be accessed by pydriller to compute the DMM metrics. If the error occurs, we just skip the metrics for this particular commit

* Skipping problematic commits/versions

* Added submodule limitation to readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant