# Bug OP-19967 - wiki_page_links pagination silently ignores offset

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-19967

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Modules and project features / Wiki, API |
| Target versions | 17.9.0 |
| Observed in versions |  |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee | Ihor Khomenko |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Before filing a report

Confirmed reproducible on the latest available patch release of the 17.7 minor line (17.7.1, the latest at the time of testing) via direct REST API calls against a real instance. Searched community.openproject.org for existing reports (by "wiki page link page not forwarded", "wiki_page_links pagination offset", "PageLinkCollectionRepresenter offset") — found no existing report covering this. Note: this is a DIFFERENT, separate bug from OP-19928 ("GET .../wiki_page_links returns 500 (invalid SQL) whenever a work package has at least one wiki page link") -- that one is a crash; this one is a silent pagination inconsistency with no error at all. A minimal, verified fix is proposed below, also submitted as a pull request: https://github.com/opf/openproject/pull/24774

### Steps to reproduce

1. Login as a user with permissions to view work packages and manage wiki page links in a project.
2. Create at least 3 wiki page links on a single work package, each pointing at a resolvable wiki page. There is only one create endpoint for this resource, the global (not work-package-scoped) `POST /api/v3/wiki_page_links`, which accepts the target work package as one of the link's own attributes; the work-package-scoped path below only supports GET.
3. Call `GET /api/v3/work_packages/{id}/wiki_page_links?pageSize=2&offset=1`, note the returned element ids.
4. Call `GET /api/v3/work_packages/{id}/wiki_page_links?pageSize=2&offset=2`.
5. (The same bug is independently reproducible on the global, non-work-package-scoped read endpoint: `GET /api/v3/wiki_page_links?pageSize=2&offset=1` vs. `offset=2`, using links across any work packages the user can view.)

### What is the buggy behavior?

Both requests in step 3 and step 4 return the SAME elements (e.g. ids `[21, 20]` both times) -- `offset=2` does not actually advance to the next page. The response incorrectly reports `offset: 1` (and its self link uses offset 1) regardless of the `offset` requested, while `total` correctly reports the full count. No error is raised; this is a silent correctness bug, not a crash.

Root cause: both the work-package-scoped handler (`modules/wikis/lib/api/v3/page_links/work_package_wiki_page_links_api.rb`) and the global handler (`modules/wikis/lib/api/v3/page_links/page_links_api.rb`) construct their response like this:
```ruby
PageLinkCollectionRepresenter.new(
  enrich_models_with_wiki_metadata(relation).result,
  per_page: params[:pageSize],
  self_link: api_v3_paths.work_package_wiki_page_links(@work_package.id),
  current_user:
)
```
Neither passes `page:` -- only `per_page:`. `API::Decorators::OffsetPaginatedCollection#initialize` defaults `page` to `1` whenever it is not explicitly given, and its `offset` response property simply reads back that same `@page` value, so every call to either endpoint always renders (and reports) page 1 of the underlying relation, silently ignoring the client's `offset` query parameter.

### What is the expected behavior?

`offset`/`page` should behave the same way it does on every other paginated collection endpoint in the API: passing `offset=2` should return the second page of results, distinct from `offset=1`, and the response should correctly report `offset: 2` (rather than always `1`) -- while preserving the already-correct `total`.

### Logs

Not applicable — no error is raised; the bug is a silent, incorrect response body rather than an exception or log entry.

### Screenshots and other files

None — this is a pure backend/API bug with no UI reproduction path tested; the REST API reproduction above is sufficient to demonstrate it independent of any client.

### Environment information

**OpenProject installation type**

* Docker All-in-one container (official `openproject/openproject` image: `17.7.1`)

**OpenProject version**

Reproduced on `17.7.1` (the latest release in the 17.7 line at the time of testing). Confirmed present unchanged in source on the `dev` branch (checked against the full source checkout).

**Browser**

Not applicable — reproduced via direct REST API calls, no browser involved.

**Operating System**

Not applicable — server-side bug, reproduced against a Linux-based Docker container; the client OS is irrelevant to the reproduction.

**Language**

Not applicable — no UI/browser interaction involved in the reproduction.
