# Bug OP-13144 - Shared calendar return 404 when using a parent filter

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 13.0.1 |
| Observed in versions |  |
| Sprint | 13.0.1 |
| 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 |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### Steps to reproduce

*Please write down the steps to reproduce. Try to write down all necessary preconditions (what permissions do you have, are other users involved?). Example:*

1.  Login as a user in a project
2.  Make sure the project is not public, has at least one work package, and has the calendar module enabled
3.  Create a new calendar, not public
4.  Add a "Parent" filter to the calendar. Select any work package as the value.
5.  Save the calendar
6.  Click the three dots menu in the top right corner and select "Subscribe to calendar", type a name, and click "Copy URL"
7.  Try using this URL in a calendar software
    1.  alternatively, you can run `curl <the-ical-url>` in a console
    2.  or you can also open a private navigation window in the browser and try to open the url

### What is the buggy behavior?

  - It displays a 404 error
      - If you try to remove the parent filter and save the calendar, it works as expected

### What is the expected behavior?

1.  Using a shared calendar should work regardless of the filters being used

This issue occurred to Corinna. We analyzed it with Markus. It comes from the validation of the query object in the `Queries::ICalSharingContract` validation. It uses the `User.current` when validating the filters, instead of using the user given to the contract.  
This happens in `app/models/queries/work_packages/filter/filter_for_wp_mixin.rb:79` when trying to determine the `allowed_values_subset`, `WorkPackage.visible` is called without passing a user. So the current user is used, and it's the anonymous user which does not have access to any work packages of the project, meaning the filter is using invalid values and the request will fail with a 404.

### Environment information

**OpenProject installation type**

- [ ] Hosted cloud edition
- [ ] Packaged installation
    - What distribution?
- [ ] Docker All-in-one container
- [ ] Docker-compose installation
- [x] Other (please specify)
  - [x] reproduce on edge 13.1.0.598775982f
