# Bug OP-18510 - Required project attributes not enforced on POST /api/v3/projects

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Modules and project features / Project attributes, Modules and project features / Project creation, API |
| Target versions | 17.0.1 |
| Observed in versions | 16.6.0 |
| Sprint | 17.0.1 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 16.6.x |
| 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 | Attila Dombi |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### Steps to reproduce

  - Have required project attributes configured that are also "For all projects"
    
      - The don't have a default value

  - Sending `POST /api/v3/projects` with

<!-- end list -->

``` text
{
    "name": "A project created via the api"
}
```

  - This will return errors

<!-- end list -->

``` text
{
    "_type": "Error",
    "errorIdentifier": "urn:openproject-org:api:v3:errors:MultipleErrors",
    "message": "Multiple field constraints have been violated.",
    "_embedded": {
        "errors": [
            {
                "_type": "Error",
                "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
                "message": "Admin only cf (required) can't be blank.",
                "_embedded": {
                    "details": {
                        "attribute": "customField676"
                    }
                }
            },
            {
                "_type": "Error",
                "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
                "message": "Required List cf (for all) can't be blank.",
                "_embedded": {
                    "details": {
                        "attribute": "customField514"
                    }
                }
            },
            {
                "_type": "Error",
                "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
                "message": "Required date cf (not for all) can't be blank.",
                "_embedded": {
                    "details": {
                        "attribute": "customField677"
                    }
                }
            }
        ]
    }
}
```

  - Send another request with

<!-- end list -->

``` text
{
    "customField525": 5,
    "name": "A project created via the api"
}
```

Please notice that this is another, non required, non active for all, project custom field

### What is the buggy behavior?

  - The project is just created when it shouldn't as it is missing values for those required fields.

  - Additionally required custom fields without the `is_for_all` flag are also validated, and they shouldn't.

### What is the expected behavior?

1.  The required, "for all projects" project attributes should be enforced on project creation

2.  Do not validate required custom fields with `is_for_all` set to `false`.
