Unable to fork a project to a personal namespace using a service account
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Users are not able to create a fork using service account
Steps to reproduce
- Create a service account
- Add the service account as an owner into the group with the project you want to fork
- Attempt to fork the project using the API:
curl --header "PRIVATE-TOKEN: glpat-xxx" -i -X POST "https://<instance_url>/api/v4/projects/:id/fork"
- You'll get the following response:
{"message":["Limit reached You cannot create projects in your personal namespace. Contact your GitLab administrator."]}
- Adding the
namespace_path
attribute allows the project to be forked:
``` curl --header "PRIVATE-TOKEN: glpat-" --data "namespace_path=forking" --request POST "https:///api/v4/projects/7/fork" {"id":11,"description":null,"name":"protected","name_with_namespace":"forking / protected","path":"protected","path_with_namespace":"forking/protected","created_at":"2024-11-05T11:15:36.503Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"git@:forking/protected.git","http_url_to_repo":"https:///forking/protected.git","web_url":"https:///forking/protected","readme_url":null,"forks_count":0,"avatar_url":null,"star_count":0,"last_activity_at":"2024-11-05T11:15:36.453Z","namespace":{"id":20,"name":"forking","path":"forking","kind":"group","full_path":"forking","parent_id":null,"avatar_url":null,"web_url":"https:///groups/forking"},"forked_from_project":{"id":7,"description":null,"name":"protected","name_with_namespace":"test / protected","path":"protected","path_with_namespace":"test/protected","created_at":"2024-09-23T16:42:15.306Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"git@:test/protected.git","http_url_to_repo":"https:///test/protected.git","web_url":"https:///test/protected","readme_url":"https:///test/protected/-/blob/main/README.md","forks_count":1,"avatar_url":null,"star_count":0,"last_activity_at":"2024-10-04T15:14:21.841Z","namespace":{"id":2,"name":"test","path":"test","kind":"group","full_path":"test","parent_id":null,"avatar_url":null,"web_url":"https:///groups/test"}},"container_registry_image_prefix":":5050/forking/protected","_links":{"self":"https:///api/v4/projects/11","issues":"https:///api/v4/projects/11/issues","merge_requests":"https:///api/v4/projects/11/merge_requests","repo_branches":"https:///api/v4/projects/11/repository/branches","labels":"https:///api/v4/projects/11/labels","events":"https:///api/v4/projects/11/events","members":"https:///api/v4/projects/11/members","cluster_agents":"https:///api/v4/projects/11/cluster_agents"},"packages_enabled":true,"empty_repo":true,"archived":false,"visibility":"public","resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","enabled":false,"keep_n":10,"older_than":"90d","name_regex":".*","name_regex_keep":null,"next_run_at":"2024-11-06T11:15:36.544Z"},"repository_object_format":"sha1","issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"container_registry_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","analytics_access_level":"enabled","container_registry_access_level":"enabled","security_and_compliance_access_level":"private","releases_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","model_experiments_access_level":"enabled","model_registry_access_level":"enabled","emails_disabled":false,"emails_enabled":true,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":6,"mr_default_target_self":false,"import_url":null,"import_type":null,"import_status":"scheduled","import_error":null,"open_issues_count":0,"description_html":"","updated_at":"2024-11-05T11:15:36.503Z","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_forward_deployment_rollback_allowed":true,"ci_job_token_scope_enabled":false,"ci_separated_caches":true,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"ci_id_token_sub_claim_components":["project_path","ref_type","ref"],"build_git_strategy":"fetch","keep_latest_artifact":true,"restrict_user_defined_variables":false,"ci_pipeline_variables_minimum_override_role":"maintainer","runners_token":"GR1348941K47onsHsBbXjo6rvSTa5","runner_token_expiration_interval":null,"group_runners_enabled":true,"auto_cancel_pending_pipelines":"enabled","build_timeout":3600,"auto_devops_enabled":true,"auto_devops_deploy_strategy":"continuous","ci_push_repository_for_job_token_allowed":false,"ci_config_path":null,"public_jobs":true,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"suggestion_commit_message":null,"merge_commit_template":null,"squash_commit_template":null,"issue_branch_template":null,"warn_about_potentially_unwanted_characters":true,"autoclose_referenced_issues":true,"approvals_before_merge":0,"mirror":false,"external_authorization_classification_label":null,"marked_for_deletion_at":null,"marked_for_deletion_on":null,"requirements_enabled":false,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"compliance_frameworks":[],"issues_template":null,"merge_requests_template":null,"ci_restrict_pipeline_cancellation_role":"developer","merge_pipelines_enabled":false,"merge_trains_enabled":false,"merge_trains_skip_train_allowed":false,"allow_pipeline_trigger_approve_deployment":false} ```
What is the current bug behavior?
Forking fails with the {"message":["Limit reached You cannot create projects in your personal namespace. Contact your GitLab administrator."]}
message
What is the expected correct behavior?
Forking should be allowed to the personal namespace of the service accountt
Relevant logs and/or screenshots
{"time":"2024-10-29T07:26:50.095Z","severity":"INFO","duration_s":0.19881,"db_duration_s":0.0664,"view_duration_s":0.13241,"status":409,"method":"POST","path":"/api/v4/projects/6/fork","params":[],"host":"<instance_id>","remote_ip":"105.163.156.101, 105.163.156.101","ua":"curl/8.7.1","route":"/api/:version/projects/:id/fork","user_id":5,"username":"service_account_f53c5ff06d2d5044c3b5691be0847497","token_type":"PersonalAccessToken","token_id":4,"queue_duration_s":0.039862,"redis_calls":18,"redis_duration_s":0.0037229999999999997,"redis_read_bytes":1825,"redis_write_bytes":1004,"redis_cache_calls":3,"redis_cache_duration_s":0.000578,"redis_cache_read_bytes":115,"redis_cache_write_bytes":97,"redis_db_load_balancing_calls":2,"redis_db_load_balancing_duration_s":0.000507,"redis_db_load_balancing_write_bytes":53,"redis_feature_flag_calls":10,"redis_feature_flag_duration_s":0.001807,"redis_feature_flag_read_bytes":1708,"redis_feature_flag_write_bytes":565,"redis_shared_state_calls":3,"redis_shared_state_duration_s":0.000831,"redis_shared_state_read_bytes":2,"redis_shared_state_write_bytes":289,"db_count":23,"db_write_count":1,"db_cached_count":0,"db_txn_count":0,"db_replica_txn_count":0,"db_primary_txn_count":0,"db_main_txn_count":0,"db_ci_txn_count":0,"db_main_replica_txn_count":0,"db_ci_replica_txn_count":0,"db_replica_count":0,"db_primary_count":23,"db_main_count":23,"db_ci_count":0,"db_main_replica_count":0,"db_ci_replica_count":0,"db_replica_cached_count":0,"db_primary_cached_count":0,"db_main_cached_count":0,"db_ci_cached_count":0,"db_main_replica_cached_count":0,"db_ci_replica_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_main_wal_count":0,"db_ci_wal_count":0,"db_main_replica_wal_count":0,"db_ci_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_main_wal_cached_count":0,"db_ci_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_ci_replica_wal_cached_count":0,"db_replica_txn_max_duration_s":0.0,"db_primary_txn_max_duration_s":0.0,"db_main_txn_max_duration_s":0.0,"db_ci_txn_max_duration_s":0.0,"db_main_replica_txn_max_duration_s":0.0,"db_ci_replica_txn_max_duration_s":0.0,"db_replica_txn_duration_s":0.0,"db_primary_txn_duration_s":0.0,"db_main_txn_duration_s":0.0,"db_ci_txn_duration_s":0.0,"db_main_replica_txn_duration_s":0.0,"db_ci_replica_txn_duration_s":0.0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.035,"db_main_duration_s":0.035,"db_ci_duration_s":0.0,"db_main_replica_duration_s":0.0,"db_ci_replica_duration_s":0.0,"cpu_s":0.172202,"mem_objects":77545,"mem_bytes":9024478,"mem_mallocs":39102,"mem_total_bytes":12126278,"pid":29492,"worker_id":"puma_3","rate_limiting_gates":[],"exclusive_lock_requested_count":1,"exclusive_lock_wait_duration_s":0,"exclusive_lock_hold_duration_s":0.003616648,"correlation_id":"01JBBJQ4FP8XM3HRP5PPD3P22X","meta.caller_id":"POST /api/:version/projects/:id/fork","meta.remote_ip":"105.163.156.101","meta.feature_category":"source_code_management","meta.user":"service_account_f53c5ff06d2d5044c3b5691be0847497","meta.user_id":5,"meta.project":"test/protected_branch","meta.root_namespace":"test","meta.client_id":"user/5","content_length":"0","request_urgency":"default","target_duration_s":1}
Output of checks
Results of GitLab environment info
Results of GitLab application Check
Possible fixes
Edited by 🤖 GitLab Bot 🤖