Skip to content

fix(ep_approval): Fix error handling, add test for single record flow - #917

Open
sakshamarora1 wants to merge 6 commits into
CERNDocumentServer:masterfrom
sakshamarora1:fix/ep_approval
Open

fix(ep_approval): Fix error handling, add test for single record flow#917
sakshamarora1 wants to merge 6 commits into
CERNDocumentServer:masterfrom
sakshamarora1:fix/ep_approval

Conversation

@sakshamarora1

Copy link
Copy Markdown
Contributor

Fixes: #912
Also makes the code ready for the migration script: https://gitlab.cern.ch/cds-team/production_scripts/-/merge_requests/59
Related: #908

Comment thread site/cds_rdm/components.py Outdated
Comment thread site/cds_rdm/components.py Outdated
Comment thread site/cds_rdm/components.py Outdated
return False
# Migrated case: both flags point at the same version, so only the current version carries apprn
if approved_internal == source_internal:
return record["id"] == source_internal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, that wil regenerate the apprn only for the accepted version. The truth is that all the newer versions should have the apprn number

@kpsherva kpsherva moved this to In review 🔍 in Sprint Q3 2026 ☀️ Aug 19, 2026
@zzacharo
zzacharo force-pushed the fix/ep_approval branch 3 times, most recently from 86a2477 to bba3e2e Compare September 1, 2026 15:15
sakshamarora1 and others added 4 commits September 2, 2026 11:48
The condition prevented the reviewed-version link from rendering when
the draft and record share the same id, which is wrong for the
single-record migration flow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _regenerate_apprn_identifier now keeps any apprn entries already on
  the record (e.g. placed by the migration script), deduplicating by
  value and always placing the committee_approval reportnumber first.
- Simplify the apprn lookup in detail.html using selectattr/first
  instead of a namespace + for-loop.
- Switch apprn validator to always_valid so migrated identifiers are
  not rejected during subsequent edits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pf["committee_approval"] = {
**ea,
"approved_public_version": new_record_id,
"source_public_version": src_id,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we have documentation describing these keys?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I will add some documentation in our internal docs

def _validate_identifier_changes(self, identity, data, record, errors):
"""Raise ValidationError if a non-system identity modifies apprn."""
if identity.id == system_user_id:
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't this raise instead of return to keep inline with the docstring?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but we return if the user is system. We raise for non-system users as per docstring, do I miss something?

Comment thread .invenio
author_email = info@cds-rdm.com
year = 2022
python_version = 3.9
python_version = 3.14

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this leftover?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure if we are still using that, but I upgraded locally to 3.14 and upgraded the information there too.

Comment thread pyproject.toml
"fastjsonschema<2.22",
"invenio-assets<4.2.5"
"invenio-assets<4.2.5",
"flask-caching>=2.3.0,<2.5.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is it related to this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there is a separate commit pinning flask-cahcing, because tests were failing but it might be a leftover, I will check thanks!

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.

Bug: Manually added Approval report number vanishes when admin saves

3 participants