inveniosoftware / inveniosoftware/invenio-github
`latestdoi` badge link failing when latest record deleted
- Dominant language
- Python
- Stars
- 8
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
Package version (if known): 3.0.1
## Describe the bug
The `latestdoi` badge link is failing when then record linked to latest published release has been deleted
## Steps to Reproduce
1. Integrate with a GitHub repository and release 2 versions
2. Delete the latest record
3. Go to `/badge/latestdoi/{github_repo_id}`
4. The page fails with an internal error
## Expected behavior
The page redirects to the latest non-deleted record (or at least to the tombstone of the latest deleted record?)
## Screenshots (if applicable)
## Additional context
Execution flow:
* [This line retrieves the latest published release](https://github.com/inveniosoftware/invenio-github/blob/a841b144d26059a9e084df3729ec54b23801c6c0/invenio_github/views/badge.py#L104) (but in our case, this latest published release is linked to the deleted record)
* [Then this line tries to get the URL of the record linked to the release](https://github.com/inveniosoftware/invenio-github/blob/a841b144d26059a9e084df3729ec54b23801c6c0/invenio_github/views/badge.py#L111)
* Since the record is deleted, [`self.record` here](https://github.com/inveniosoftware/invenio-rdm-records/blob/e884535503502ffa37b5e4de38b2fbed865bf5df/invenio_rdm_records/services/github/release.py#L236) is `None`, and accessing `.data` raises `AttributeError: 'NoneType' object has no attribute 'data'`.
* The part resolving the record is in [invenio_rdm_records/services/github/release](https://github.com/inveniosoftware/invenio-rdm-records/blob/e884535503502ffa37b5e4de38b2fbed865bf5df/invenio_rdm_records/services/github/release.py#L94-L102)
To be fixed in `invenio-github` and in upcoming `invenio-vcs`.
Contributor guide
Assessment
This issue has not been assessed yet.