Skip to content

checks: passes checks to draft edit & update to return latest run #3060

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

0einstein0
Copy link
Member

@0einstein0 0einstein0 commented May 22, 2025

w:heart: Thank you for your contribution!

Description

Closes inveniosoftware/invenio-rdm-records#2051

  • Passes on check errors to edit deposit
  • Return the latest check run, preference to drafts

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@0einstein0 0einstein0 linked an issue May 22, 2025 that may be closed by this pull request
@0einstein0 0einstein0 changed the title deposit: passed checks errors to form on draft edit checks: passes checks to draft edit & update to return latest run May 27, 2025
CheckRun.query.filter(
CheckRun.config_id.in_(check_config_ids), CheckRun.record_id == record_uuid
)
.order_by(CheckRun.is_draft.desc(), CheckRun.revision_id.desc())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same feeling here, as we had in the Checks component. We should be very explicit about which check runs we're fetching, i.e. for the record or draft. Either that, or we fetch them all and sort/split them out here in code (if e.g. we plan to be able to display them both). Doing "tricks" with sorting based on is_draft and revision_id can be confusing and faulty.

@@ -209,6 +209,7 @@ def user_dashboard_request_view(request, **kwargs):
permissions=topic["permissions"],
is_preview=is_draft, # preview only when draft
is_draft=is_draft,
has_draft=record._record.has_draft,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't is_draft actually work the same? We might also need is_published though (see zenodo/zenodo-rdm#1188 (comment) )

Comment on lines +552 to +563
errors = []
record_uuid = current_rdm_records_service.draft_cls.pid.resolve(
pid_value, registered_only=False
).id
request = draft.data.get("parent", {}).get("review")
if request and record_uuid:
checks = resolve_checks(record_uuid, request) or []
errors = [
err
for check in checks
for err in (check.result.get("errors") if check.result else [])
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be needed anymore, since draft coming from read_draft(...) already has checks errors in it.

That means we can just pass errors=record.errors below?


# Early exit if not draft submission nor record inclusion
request_type = request["type"]
is_draft_submission = request_type == CommunitySubmission.type_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_draft_submission = request_type == CommunitySubmission.type_id
is_draft_review = request_type == CommunitySubmission.type_id

for naming consistency

is_draft_submission = request_type == CommunitySubmission.type_id
is_record_inclusion = request_type == CommunityInclusion.type_id

if not is_draft_submission and not is_record_inclusion:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would this be possible?

return None

# Resolve the target community from the request if the community was not passed as an argument
if not community:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which cases community will not be passed as an argument?

communities.append(community.id)

# Early exit if no check config found for the communities
from invenio_checks.models import CheckConfig, CheckRun
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why local import is needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invenio-checks is not a dependency of invenio-app-rdm by default, so this is only accessed if you have set CHECKS_ENABLED = True. We can add the dependency now, since we're getting more production usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checks leftover tasks
3 participants