When an existing study belongs to repository A but the user has subsequently made repository B primary, this call supplies no selectedRepo, so importToStudy validates B and returns B's token. The upload later reads repository A from study.json and sends that token to A, causing all resource/strain/sample-design imports in this common multi-repository scenario to fail. Read the study before starting the workflow and pass its repository and expected user into importToStudy.
When an existing study belongs to repository A but the user has subsequently made repository B primary, this call supplies no selectedRepo, so importToStudy validates B and returns B's token. The upload later reads repository A from study.json and sends that token to A, causing all resource/strain/sample-design imports in this common multi-repository scenario to fail. Read the study before starting the workflow and pass its repository and expected user into importToStudy.