Skip to content

fix(harvester): do not create records for unmatched EP approvals - #922

Open
TahaKhan998 wants to merge 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/issue-906-ep-approval-no-create
Open

fix(harvester): do not create records for unmatched EP approvals#922
TahaKhan998 wants to merge 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/issue-906-ep-approval-no-create

Conversation

@TahaKhan998

Copy link
Copy Markdown

part of #906
If an INSPIRE record has an EP approval number and it does not match an existing CDS record, the harvester raises an error and does not create a new one. Same if it matches a restricted record, that means they forgot to publish the internal version after the approval. If it matches a public record we update it as usual.

@TahaKhan998 TahaKhan998 linked an issue Aug 13, 2026 that may be closed by this pull request
6 tasks
)
if record.to_dict().get("access", {}).get("record") == "restricted":
raise WriterError(
"EP approval number matched a restricted record. "

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.

Suggested change
"EP approval number matched a restricted record. "
"EP approval number matched a restricted record - record must be public to be updated by the harvester"

just to explain to the curators what should happen

else:
if apprn:
raise WriterError(
"EP approval number did not match an existing record. "

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.

Suggested change
"EP approval number did not match an existing record. "
"EP approval number did not match an existing record - EP approval numbers can't be assigned outside CDS publishing workflow."

@TahaKhan998
TahaKhan998 force-pushed the fix/issue-906-ep-approval-no-create branch from 8913cba to 7585b20 Compare August 19, 2026 11:30
Comment on lines +91 to +94
apprn = self.matcher._retrieve_identifier(
stream_entry.entry.get("metadata", {}).get("identifiers", []),
"apprn",
)

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.

these checks should not be implemented in the route step - if you also consider the other PR which you worked on the legacy recid matching - we will end up with a very unreadable method which has multiple responsibilities to handle - which is not the best practice.
these checks should have an additional validation class, organised similarly (composition) as the mappers - different validation workflow while updating the record and different while creating.

we are aiming to see, inside _update_record method something like

self.record_validator.validate(mode="update")

similar for the create mode

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.

harverster feedback it2

2 participants