xanzy / go-gitlab

GitLab Go SDK
Apache License 2.0
2.42k stars 957 forks source link

Cannot get/set Settings #2033

Closed cyd01 closed 4 weeks ago

cyd01 commented 1 month ago

I have an issue when retrieving or sending settings using glabCli.Settings.UpdateSettings(newSettings) and glabCli.Settings.GetSettings().

The functions GetSettings & UpdateSettingsalways return a non-nil error with value:

json: cannot unmarshal object into Go struct field BranchProtectionDefaults.default_branch_protection_defaults.allowed_to_merge of type int

I use Gitlab version 17.4.2 and go-gitlab v0.111.0.

svanharmelen commented 1 month ago

Do you have an (obfuscated) example of the JSON being returned by the server?

cyd01 commented 1 month ago

Here it is:

{
  "id": 1,
  "performance_bar_allowed_group_id": null,
  "abuse_notification_email": null,
  "admin_mode": false,
  "after_sign_out_path": "",
  "after_sign_up_text": "",
  "akismet_api_key": null,
  "akismet_enabled": false,
  "allow_local_requests_from_web_hooks_and_services": true,
  "allow_local_requests_from_system_hooks": true,
  "allow_possible_spam": false,
  "dns_rebinding_protection_enabled": true,
  "archive_builds_in_human_readable": null,
  "asset_proxy_enabled": false,
  "asset_proxy_url": null,
  "asset_proxy_allowlist": [],
  "static_objects_external_storage_auth_token": null,
  "static_objects_external_storage_url": null,
  "authorized_keys_enabled": true,
  "auto_devops_enabled": true,
  "auto_devops_domain": "",
  "concurrent_github_import_jobs_limit": 1000,
  "concurrent_bitbucket_import_jobs_limit": 100,
  "concurrent_bitbucket_server_import_jobs_limit": 100,
  "container_expiration_policies_enable_historic_entries": false,
  "container_registry_expiration_policies_caching": true,
  "container_registry_token_expire_delay": 5,
  "decompress_archive_file_timeout": 210,
  "default_artifacts_expire_in": "30 days",
  "default_branch_name": null,
  "default_branch_protection": 2,
  "default_branch_protection_defaults": {
    "allowed_to_push": [
      {
        "access_level": 40
      }
    ],
    "allow_force_push": false,
    "allowed_to_merge": [
      {
        "access_level": 40
      }
    ]
  },
  "default_ci_config_path": "",
  "default_group_visibility": "private",
  "default_preferred_language": "en",
  "default_project_creation": 2,
  "default_project_visibility": "private",
  "default_projects_limit": 100000,
  "default_snippet_visibility": "private",
  "default_syntax_highlighting_theme": 1,
  "delete_inactive_projects": false,
  "deny_all_requests_except_allowed": false,
  "disable_admin_oauth_scopes": false,
  "disable_feed_token": false,
  "disabled_oauth_sign_in_sources": [],
  "domain_denylist": [],
  "domain_denylist_enabled": false,
  "domain_denylist_raw": "",
  "domain_allowlist": [
    "outlook.com"
  ],
  "domain_allowlist_raw": "outlook.com",
  "outbound_local_requests_allowlist_raw": "127.0.0.0/24\n10.0.0.0/8\n172.16.0.0/12\n192.168.0.0/16",
  "dsa_key_restriction": 0,
  "ecdsa_key_restriction": 0,
  "ecdsa_sk_key_restriction": 0,
  "ed25519_key_restriction": 0,
  "ed25519_sk_key_restriction": 0,
  "eks_integration_enabled": false,
  "eks_account_id": null,
  "eks_access_key_id": null,
  "email_author_in_body": false,
  "email_confirmation_setting": "hard",
  "enabled_git_access_protocol": null,
  "enforce_terms": false,
  "error_tracking_enabled": false,
  "error_tracking_api_url": null,
  "external_pipeline_validation_service_timeout": null,
  "external_pipeline_validation_service_token": null,
  "external_pipeline_validation_service_url": null,
  "failed_login_attempts_unlock_period_in_minutes": null,
  "first_day_of_week": 1,
  "floc_enabled": false,
  "force_pages_access_control": false,
  "gitaly_timeout_default": 55,
  "gitaly_timeout_medium": 30,
  "gitaly_timeout_fast": 10,
  "gitpod_enabled": false,
  "gitpod_url": "https://gitpod.io/",
  "grafana_enabled": false,
  "grafana_url": "/-/grafana/",
  "gravatar_enabled": true,
  "hashed_storage_enabled": true,
  "help_page_hide_commercial_content": false,
  "help_page_support_url": null,
  "help_page_documentation_base_url": null,
  "help_page_text": null,
  "hide_third_party_offers": false,
  "home_page_url": "",
  "housekeeping_enabled": true,
  "housekeeping_full_repack_period": 10,
  "housekeeping_gc_period": 10,
  "housekeeping_incremental_repack_period": 10,
  "housekeeping_optimize_repository_period": 10,
  "html_emails_enabled": true,
  "import_sources": [
    "github",
    "bitbucket",
    "bitbucket_server",
    "fogbugz",
    "git",
    "gitlab_project",
    "gitea",
    "manifest"
  ],
  "inactive_projects_delete_after_months": 2,
  "inactive_projects_min_size_mb": 0,
  "inactive_projects_send_warning_email_after_months": 1,
  "include_optional_metrics_in_service_ping": true,
  "invisible_captcha_enabled": false,
  "jira_connect_application_key": null,
  "jira_connect_public_key_storage_enabled": false,
  "jira_connect_proxy_url": null,
  "math_rendering_limits_enabled": true,
  "max_artifacts_content_include_size": 5242880,
  "max_artifacts_size": 100,
  "max_attachment_size": 200,
  "max_decompressed_archive_size": 25600,
  "max_export_size": 0,
  "max_import_size": 200,
  "max_import_remote_file_size": 10240,
  "max_login_attempts": null,
  "max_pages_size": 100,
  "max_pages_custom_domains_per_project": 0,
  "max_terraform_state_size_bytes": 0,
  "max_yaml_size_bytes": 2097152,
  "max_yaml_depth": 100,
  "metrics_method_call_threshold": 10,
  "minimum_password_length": 8,
  "mirror_available": true,
  "notify_on_unknown_sign_in": true,
  "pages_domain_verification_enabled": true,
  "password_authentication_enabled_for_web": true,
  "password_authentication_enabled_for_git": true,
  "personal_access_token_prefix": "",
  "kroki_enabled": false,
  "kroki_url": null,
  "kroki_formats": {},
  "plantuml_enabled": false,
  "plantuml_url": null,
  "diagramsnet_enabled": true,
  "diagramsnet_url": "https://embed.diagrams.net",
  "pages_extra_deployments_default_expiry_seconds": 86400,
  "polling_interval_multiplier": "1.0",
  "project_export_enabled": true,
  "prometheus_metrics_enabled": true,
  "recaptcha_enabled": false,
  "recaptcha_private_key": null,
  "recaptcha_site_key": null,
  "login_recaptcha_protection_enabled": false,
  "receive_max_input_size": null,
  "repository_checks_enabled": true,
  "require_admin_approval_after_user_signup": true,
  "require_admin_two_factor_authentication": false,
  "require_two_factor_authentication": true,
  "remember_me_enabled": true,
  "restricted_visibility_levels": [],
  "rsa_key_restriction": 0,
  "session_expire_delay": 10080,
  "shared_runners_enabled": true,
  "shared_runners_text": "",
  "signup_enabled": false,
  "silent_mode_enabled": false,
  "slack_app_enabled": false,
  "slack_app_id": null,
  "slack_app_secret": null,
  "slack_app_signing_secret": null,
  "slack_app_verification_token": null,
  "sourcegraph_enabled": false,
  "sourcegraph_url": "",
  "sourcegraph_public_only": true,
  "spam_check_endpoint_enabled": false,
  "spam_check_endpoint_url": null,
  "spam_check_api_key": null,
  "terminal_max_session_time": 0,
  "terms": null,
  "throttle_authenticated_api_enabled": false,
  "throttle_authenticated_api_period_in_seconds": 3600,
  "throttle_authenticated_api_requests_per_period": 7200,
  "throttle_authenticated_git_lfs_enabled": false,
  "throttle_authenticated_git_lfs_period_in_seconds": 60,
  "throttle_authenticated_git_lfs_requests_per_period": 1000,
  "throttle_authenticated_web_enabled": false,
  "throttle_authenticated_web_period_in_seconds": 3600,
  "throttle_authenticated_web_requests_per_period": 7200,
  "throttle_authenticated_packages_api_enabled": false,
  "throttle_authenticated_packages_api_period_in_seconds": 15,
  "throttle_authenticated_packages_api_requests_per_period": 1000,
  "throttle_authenticated_files_api_enabled": false,
  "throttle_authenticated_files_api_period_in_seconds": 15,
  "throttle_authenticated_files_api_requests_per_period": 500,
  "throttle_authenticated_deprecated_api_enabled": false,
  "throttle_authenticated_deprecated_api_period_in_seconds": 1800,
  "throttle_authenticated_deprecated_api_requests_per_period": 3600,
  "throttle_unauthenticated_api_enabled": false,
  "throttle_unauthenticated_api_period_in_seconds": 3600,
  "throttle_unauthenticated_api_requests_per_period": 3600,
  "throttle_unauthenticated_enabled": false,
  "throttle_unauthenticated_period_in_seconds": 3600,
  "throttle_unauthenticated_requests_per_period": 3600,
  "throttle_unauthenticated_packages_api_enabled": false,
  "throttle_unauthenticated_packages_api_period_in_seconds": 15,
  "throttle_unauthenticated_packages_api_requests_per_period": 800,
  "throttle_unauthenticated_files_api_enabled": false,
  "throttle_unauthenticated_files_api_period_in_seconds": 15,
  "throttle_unauthenticated_files_api_requests_per_period": 125,
  "throttle_unauthenticated_git_http_enabled": false,
  "throttle_unauthenticated_git_http_period_in_seconds": 3600,
  "throttle_unauthenticated_git_http_requests_per_period": 3600,
  "throttle_unauthenticated_deprecated_api_enabled": false,
  "throttle_unauthenticated_deprecated_api_period_in_seconds": 3600,
  "throttle_unauthenticated_deprecated_api_requests_per_period": 3600,
  "throttle_protected_paths_enabled": false,
  "throttle_protected_paths_period_in_seconds": 60,
  "throttle_protected_paths_requests_per_period": 10,
  "protected_paths_raw": "/users/password\n/users/sign_in\n/api/v3/session.json\n/api/v3/session\n/api/v4/session.json\n/api/v4/session\n/users\n/users/confirmation\n/unsubscribes/\n/import/github/personal_access_token\n/admin/session",
  "protected_paths_for_get_request_raw": "",
  "time_tracking_limit_to_hours": false,
  "two_factor_grace_period": 48,
  "update_runner_versions_enabled": true,
  "unique_ips_limit_enabled": false,
  "unique_ips_limit_per_user": 10,
  "unique_ips_limit_time_window": 3600,
  "usage_ping_enabled": true,
  "usage_ping_features_enabled": false,
  "user_default_external": false,
  "user_show_add_ssh_key_message": true,
  "user_default_internal_regex": "",
  "user_oauth_applications": true,
  "version_check_enabled": true,
  "diff_max_patch_bytes": 204800,
  "diff_max_files": 1000,
  "diff_max_lines": 50000,
  "commit_email_hostname": "users.noreply.eb46ea6dbace",
  "protected_ci_variables": true,
  "local_markdown_version": 0,
  "mailgun_signing_key": null,
  "mailgun_events_enabled": false,
  "snowplow_collector_hostname": null,
  "snowplow_cookie_domain": null,
  "snowplow_database_collector_hostname": null,
  "snowplow_enabled": false,
  "snowplow_app_id": null,
  "push_event_hooks_limit": 3,
  "push_event_activities_limit": 3,
  "custom_http_clone_url_root": null,
  "snippet_size_limit": 52428800,
  "email_restrictions_enabled": false,
  "email_restrictions": "",
  "issues_create_limit": 300,
  "notes_create_limit": 300,
  "notes_create_limit_allowlist_raw": "",
  "members_delete_limit": 60,
  "raw_blob_request_limit": 300,
  "project_import_limit": 10,
  "project_export_limit": 600,
  "project_download_export_limit": 100,
  "group_import_limit": 6,
  "group_export_limit": 600,
  "group_download_export_limit": 100,
  "wiki_page_max_content_bytes": 52428800,
  "wiki_asciidoc_allow_uri_includes": false,
  "container_registry_delete_tags_service_timeout": 100,
  "rate_limiting_response_text": null,
  "package_registry_allow_anyone_to_pull_option": true,
  "package_registry_cleanup_policies_worker_capacity": 2,
  "container_registry_expiration_policies_worker_capacity": 4,
  "container_registry_cleanup_tags_service_max_list_size": 200,
  "keep_latest_artifact": true,
  "whats_new_variant": "all_tiers",
  "user_deactivation_emails_enabled": true,
  "sentry_enabled": false,
  "sentry_dsn": null,
  "sentry_clientside_dsn": null,
  "sentry_environment": null,
  "sentry_clientside_traces_sample_rate": 0,
  "sidekiq_job_limiter_mode": "compress",
  "sidekiq_job_limiter_compression_threshold_bytes": 100000,
  "sidekiq_job_limiter_limit_bytes": 0,
  "suggest_pipeline_enabled": true,
  "enable_artifact_external_redirect_warning_page": true,
  "search_rate_limit": 300,
  "search_rate_limit_unauthenticated": 100,
  "search_rate_limit_allowlist_raw": "",
  "users_get_by_id_limit": 300,
  "users_get_by_id_limit_allowlist_raw": "",
  "runner_token_expiration_interval": null,
  "group_runner_token_expiration_interval": null,
  "project_runner_token_expiration_interval": null,
  "pipeline_limit_per_project_user_sha": 0,
  "invitation_flow_enforcement": false,
  "can_create_group": true,
  "bulk_import_concurrent_pipeline_batch_limit": 25,
  "bulk_import_enabled": false,
  "bulk_import_max_download_file_size": 5120,
  "silent_admin_exports_enabled": false,
  "allow_runner_registration_token": false,
  "user_defaults_to_private_profile": false,
  "deactivation_email_additional_text": null,
  "projects_api_rate_limit_unauthenticated": 400,
  "group_api_limit": 400,
  "group_invited_groups_api_limit": 60,
  "group_shared_groups_api_limit": 60,
  "group_projects_api_limit": 600,
  "groups_api_limit": 200,
  "project_api_limit": 400,
  "project_invited_groups_api_limit": 60,
  "projects_api_limit": 2000,
  "user_contributed_projects_api_limit": 100,
  "user_projects_api_limit": 300,
  "user_starred_projects_api_limit": 100,
  "gitlab_dedicated_instance": false,
  "gitlab_environment_toolkit_instance": false,
  "ci_max_includes": 150,
  "allow_account_deletion": true,
  "gitlab_shell_operation_limit": 600,
  "namespace_aggregation_schedule_lease_duration_in_seconds": 300,
  "ci_max_total_yaml_size_bytes": 314572800,
  "project_jobs_api_rate_limit": 600,
  "security_txt_content": null,
  "allow_project_creation_for_guest_and_below": true,
  "downstream_pipeline_trigger_limit_per_project_user_sha": 0,
  "asciidoc_max_includes": 32,
  "ai_action_api_rate_limit": 160,
  "code_suggestions_api_rate_limit": 60,
  "require_personal_access_token_expiry": true,
  "observability_backend_ssl_verification_enabled": true,
  "deactivate_dormant_users": false,
  "deactivate_dormant_users_period": 90,
  "nuget_skip_metadata_url_validation": false,
  "valid_runner_registrars": [
    "project",
    "group"
  ],
  "external_auth_client_cert": null,
  "external_auth_client_key": null,
  "external_auth_client_key_pass": null,
  "external_authorization_service_default_label": null,
  "external_authorization_service_enabled": false,
  "external_authorization_service_timeout": 0.5,
  "external_authorization_service_url": null,
  "allow_deploy_tokens_and_keys_with_external_authn": false,
  "throttle_unauthenticated_web_enabled": false,
  "throttle_unauthenticated_web_period_in_seconds": 3600,
  "throttle_unauthenticated_web_requests_per_period": 3600,
  "password_authentication_enabled": true,
  "signin_enabled": true,
  "allow_local_requests_from_hooks_and_services": true,
  "asset_proxy_whitelist": [],
  "housekeeping_bitmaps_enabled": true,
  "repository_storages_weighted": {
    "default": 100
  },
  "container_registry_import_max_tags_count": 0,
  "container_registry_import_max_retries": 0,
  "container_registry_import_start_max_retries": 0,
  "container_registry_import_max_step_duration": 0,
  "container_registry_pre_import_tags_rate": 0,
  "container_registry_pre_import_timeout": 0,
  "container_registry_import_timeout": 0,
  "container_registry_import_target_plan": "",
  "container_registry_import_created_before": ""
}
svanharmelen commented 4 weeks ago

@cyd01 can you test/verify if #2036 fixes the issue?

cyd01 commented 4 weeks ago

I've just checked, and yes it fixes the issue. Thanks.

svanharmelen commented 4 weeks ago

Thanks for reporting back 👍🏻