# Bug OP-10440 - Project clone with global basic auth not working

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 12.1.4 |
| Observed in versions | 12.1.0 |
| Sprint | 12.1.4 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 12.1.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 |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### **Environment**:

Your OpenProject Version: Self hosted 12.1.3 (Docker all in one container)  
Operating System / Browser / OpenProject language: Not a frontend issue, docker container on macOS / Linux host system

### **Logs**

``` text
E, [2022-05-15T22:17:17.085913 #142] ERROR -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814] Failed to finish copy project job: SMTP To address may not be blank: [] SMTP To address may not be blank: []
I, [2022-05-15T22:17:17.093173 #142]  INFO -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814]   Rendered project_mailer/copy_project_failed.html.erb within layouts/mailer (Duration: 0.3ms | Allocations: 144)
I, [2022-05-15T22:17:17.093419 #142]  INFO -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814]   Rendered layout layouts/mailer.html.erb (Duration: 0.6ms | Allocations: 293)
I, [2022-05-15T22:17:17.093837 #142]  INFO -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814]   Rendered project_mailer/copy_project_failed.text.erb within layouts/mailer (Duration: 0.2ms | Allocations: 116)
I, [2022-05-15T22:17:17.094027 #142]  INFO -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814]   Rendered layout layouts/mailer.text.erb (Duration: 0.4ms | Allocations: 259)
I, [2022-05-15T22:17:17.097267 #142]  INFO -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814] Delivered mail op.project-1.20220515221717.1@example.net (1.8ms)
E, [2022-05-15T22:17:17.097385 #142] ERROR -- : [ActiveJob] [CopyProjectJob] [b2ee8d9c-531e-4378-82b4-8dafb13f1814] Error performing CopyProjectJob (Job ID: b2ee8d9c-531e-4378-82b4-8dafb13f1814) from DelayedJob(default) in 2058.04ms: ArgumentError (SMTP To address may not be blank: []):
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/check_delivery_params.rb:21:in `check_to'
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/check_delivery_params.rb:7:in `check'
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/sendmail.rb:53:in `deliver!'
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `block in deliver'
/app/vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.5.1/lib/action_mailer/base.rb:559:in `block in deliver_mail'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.5.1/lib/active_support/notifications.rb:203:in `block in instrument'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.5.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.5.1/lib/active_support/notifications.rb:203:in `instrument'
/app/vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.5.1/lib/action_mailer/base.rb:557:in `deliver_mail'
/app/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `deliver'
/app/vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.5.1/lib/action_mailer/message_delivery.rb:119:in `block in deliver_now'
/app/vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.5.1/lib/action_mailer/rescuable.rb:17:in `handle_exceptions'
/app/vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.5.1/lib/action_mailer/message_delivery.rb:118:in `deliver_now'
/app/app/workers/copy_project_job.rb:73:in `rescue in perform'
/app/app/workers/copy_project_job.rb:42:in `perform'
/app/vendor/bundle/ruby/3.0.0/gems/activejob-6.1.5.1/lib/active_job/execution.rb:48:in `block in perform_now'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.5.1/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
/app/app/workers/application_job.rb:101:in `block in clean_context'
/app/app/workers/application_job.rb:79:in `with_clean_request_store'
/app/app/workers/application_job.rb:98:in `clean_context'
Rest of stack trace omitted for better readability.
```

### **Steps to reproduce:**

  - Start the latest (currently 12.1.3) Docker all in one container for example with

<!-- end list -->

``` sh
docker run --rm --name openproject -d \
    -p 127.0.0.1:8080:80 \
    -eOPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_USER=admin \
    -eOPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_PASSWORD=admin \
    -eOPENPROJECT_AUTH__SOURCE__SSO_HEADER=X-Remote-User \
    -eOPENPROJECT_AUTH__SOURCE__SSO_SECRET=s3cr3t \
    -eOPENPROJECT_AUTH__SOURCE__SSO_OPTIONAL=true \
    -eOPENPROJECT_EMAIL__DELIVERY__METHOD=sendmail \
    openproject/community:12.1.3
```

  - Get the id of the demo project, with for example

<!-- end list -->

``` sh
export DEMO_PROJECT_ID=$(curl --request GET --url 'http://127.0.0.1:8080/api/v3/projects?filters=%5B%7B%20%22name_and_identifier%22%3A%20%7B%20%22operator%22%3A%20%22%3D%22%2C%20%22values%22%3A%20%5B%22demo-project%22%5D%7D%7D%5D'   --header 'Authorization: Basic YWRtaW46YWRtaW4=' -s | jq "._embedded.elements[0].id")
```

  - Initiate clone of the demo project

<!-- end list -->

``` sh
export JOB_ID=$(curl -s -L \
  --url http://127.0.0.1:8080/api/v3/projects/$DEMO_PROJECT_ID/copy \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --header 'Content-Type: application/json' \
  --data '{
        "name": "Demo Project clone",
        "_meta": {
                "copyBoards": false,
                "copyCategories": false,
                "copyForums": false,
                "copyMembers": true,
                "copyOverview": false,
                "copyQueries": false,
                "copyVersions": false,
                "copyWiki": false,
                "copyWikiPageAttachments": false,
                "copyWorkPackageAttachments": false,
                "copyWorkPackages": true,
                "sendNotifications": false
        },
        "_links": {
                "parent": {}
        },
        "public": false
}' | jq -r ".jobId")
```

  - Wait for an error message in the log and then check the job status

<!-- end list -->

``` sh
curl --request GET \
  --url http://127.0.0.1:8080/api/v3/job_statuses/$JOB_ID \
  --header 'Authorization: Basic YWRtaW46YWRtaW4='
```

  - The result is the following error

<!-- end list -->

``` json
{
	"_type": "JobStatus",
	"jobId": "$JOB_ID",
	"status": "failure",
	"message": "SMTP To address may not be blank: []",
	"payload": {
		"title": "Copy project"
	},
	"_links": {
		"self": {
			"href": "/api/v3/job_statuses/$JOB_ID"
		}
	}
}
```

### **Actual Behavior**

The project clone fails with the above message and job result. Setting the mail field in the database of the system user also produces this error.

### **Expected Behavior**

The project clone should succeed.
