Skip to content

fix(publish-public): keep internal cdsrn as related idenitfier in the… - #1083

Open
zzacharo wants to merge 2 commits into
CERNDocumentServer:masterfrom
zzacharo:fix-cdsrn-on-publish-public
Open

zzacharo wants to merge 2 commits into
CERNDocumentServer:masterfrom
zzacharo:fix-cdsrn-on-publish-public

Conversation

@zzacharo

Copy link
Copy Markdown
Contributor

Committee approval: referee group from the enrollment, report numbers on public records

Two fixes found while testing the EP approval API on the sandbox for the experiments' integration guide.

1. Approval requests always go to the enrollment's referee group

POST /api/records/<id>/committee-approval took receiver_group from the request body. A community manager could send the request to any group. That group could then accept it and get a real CERN-EP report number. On the sandbox, a request sent to a group of my choice was accepted and received CERN-EP-2026-218.

  • The endpoint ignores receiver_group and uses the referee_group of the community's enrollment.
  • A community that is not enrolled now gets a 400 with "The record's community is not enrolled in the committee approval workflow." Before, it got a bare 403 "Permission denied", the same answer as a missing role.
  • CommitteeApprovalSubmitAction refuses a request whose receiver is not the referee group. This covers code that creates the request through the service directly.
  • New test: test_committee_approval_submit_rejects_other_receiver_group.

2. publish-public keeps report numbers as related identifiers

POST /api/records/<id>/committee-approval/publish-public copied the restricted record's cdsrn identifiers into the new public record. CDS report numbers are unique per record, so publishing failed with "The CDS report number '…' is already taken." No paper with its own report number (LHCb-PAPER-…, ATLAS-…) could get its public record.

  • The public record no longer has cdsrn in identifiers. Each one is added to related_identifiers as {"scheme": "cdsrn", "relation_type": {"id": "isvariantformof"}}, with the resource type. This is the shape the INSPIRE harvester writes and RelatedReportNumberMatchFilter matches on.
  • The restricted record keeps its report numbers.

Changes for API clients

  • receiver_group in the committee approval body is ignored. The frontend still sends it, which is harmless.
  • Not enrolled: 400 instead of 403.

zzacharo and others added 2 commits November 18, 2026 16:06
The committee approval endpoint took the receiver group from the request
body, so an API client could send the request to any group. That group
could then accept it and get an approval report number.

* views: ignore any client-provided receiver_group and use the referee
  group of the record community's enrollment. Return a 400 with a clear
  message when the community is not enrolled, instead of a bare 403.
* submit action: refuse a request whose receiver is not the
  enrollment's referee group, which also covers callers that create the
  request through the service directly.
* tests: cover a request sent to another group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ecord

Creating the public record copied the CDS report numbers (cdsrn) of the
restricted record into its identifiers. Report numbers are unique per
record, so publishing failed with "The CDS report number ... is already
taken" for every paper that carries its own report number.

The public record now leaves cdsrn out of its identifiers and gets each
one as a related identifier (scheme cdsrn, relation isvariantformof), the
same shape the INSPIRE harvester writes and matches on. The restricted
record keeps the report numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zzacharo
zzacharo force-pushed the fix-cdsrn-on-publish-public branch from 1da8654 to 85185d9 Compare November 18, 2026 16:09
@zzacharo
zzacharo marked this pull request as ready for review November 18, 2026 16:09

# Only the enrollment's referee group may receive (and so accept) the
# request, whatever receiver the caller passed.
if self.request.receiver.reference_dict != {"group": enrollment.referee_group}:

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 user provided receiver_group is popped in views.py is this even a possibility?

# The receiver always comes from the community's enrollment. A
# client-provided ``receiver_group`` is ignored so that callers cannot
# route the request (and its accept action) to a group of their choice.
body.pop("receiver_group", None)

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.

isn't the request body validated against a schema where the existence of this field could raise a validation error?

This branch has not been deployed

No deployments
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.

2 participants