Skip to content

fix(license): ensure IP address is included in anonymous user payload#163

Open
amadulhaxxani wants to merge 2 commits into
clarin-v7from
158-bad-request-payload-for-anonymous-user-confirming-the-license
Open

fix(license): ensure IP address is included in anonymous user payload#163
amadulhaxxani wants to merge 2 commits into
clarin-v7from
158-bad-request-payload-for-anonymous-user-confirming-the-license

Conversation

@amadulhaxxani

Copy link
Copy Markdown

Problem description

When an anonymous user accepts a CLARIN license that does not require any additional user fields, the POST request to /core/clarinusermetadata/manage is sent with an empty body.
This happens because userMetadata$ is never initialised for anonymous users – the loadUserRegistrationAndUserMetadata() method is only called for authenticated users. As a result, the IP address is missing from the payload and the backend rejects the request.

Analysis

The accept() method expects userMetadata$.value.page to be an array before it pushes the IP metadata. For anonymous users who do not interact with any form fields, this array remains undefined.
The fix initialises an empty page array using buildPaginatedList before the IP filtering logic, ensuring the IP metadata is always included.
Unit tests were added to cover the two affected cases: userMetadata$ is null, and userMetadata$ has an empty page array.

Copilot review

  • Requested review from Copilot

Copilot AI review requested due to automatic review settings July 1, 2026 07:59
@amadulhaxxani amadulhaxxani linked an issue Jul 1, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes anonymous CLARIN license acceptance by ensuring the POST payload to the CLARIN user metadata manage endpoint always includes an IP metadata entry, even when no extra fields are required and userMetadata$ was never initialized for anonymous users.

Changes:

  • Initialize userMetadata$ to an empty PaginatedList when missing (or when its page is missing) before filtering/pushing the IP entry.
  • Add unit tests covering anonymous-user acceptance when userMetadata$ is null and when it contains an empty page array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/app/bitstream-page/clarin-license-agreement-page/clarin-license-agreement-page.component.ts Initializes userMetadata$ to guarantee an array exists for adding the IP metadata before sending the POST request.
src/app/bitstream-page/clarin-license-agreement-page/clarin-license-agreement-page.component.spec.ts Adds tests asserting the request payload contains the IP metadata for anonymous users in the two affected initialization states.

@amadulhaxxani amadulhaxxani force-pushed the 158-bad-request-payload-for-anonymous-user-confirming-the-license branch from d87e662 to 0e911f3 Compare July 1, 2026 09:27
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.

Bad request payload for anonymous user confirming the license

2 participants