|
3 | 3 |
|
4 | 4 | from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler |
5 | 5 | from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler |
| 6 | +from pr_agent.algo.cli_args import CliArgs |
6 | 7 | from pr_agent.algo.utils import update_settings_from_args |
7 | 8 | from pr_agent.config_loader import get_settings |
8 | 9 | from pr_agent.git_providers.utils import apply_repo_settings |
@@ -60,25 +61,15 @@ async def handle_request(self, pr_url, request, notify=None) -> bool: |
60 | 61 | else: |
61 | 62 | action, *args = request |
62 | 63 |
|
63 | | - forbidden_cli_args = ['enable_auto_approval', 'approve_pr_on_self_review', 'base_url', 'url', 'app_name', 'secret_provider', |
64 | | - 'git_provider', 'skip_keys', 'openai.key', 'ANALYTICS_FOLDER', 'uri', 'app_id', 'webhook_secret', |
65 | | - 'bearer_token', 'PERSONAL_ACCESS_TOKEN', 'override_deployment_type', 'private_key', |
66 | | - 'local_cache_path', 'enable_local_cache', 'jira_base_url', 'api_base', 'api_type', 'api_version', |
67 | | - 'skip_keys'] |
68 | | - if args: |
69 | | - for arg in args: |
70 | | - if arg.startswith('--'): |
71 | | - arg_word = arg.lower() |
72 | | - arg_word = arg_word.replace('__', '.') # replace double underscore with dot, e.g. --openai__key -> --openai.key |
73 | | - for forbidden_arg in forbidden_cli_args: |
74 | | - forbidden_arg_word = forbidden_arg.lower() |
75 | | - if '.' not in forbidden_arg_word: |
76 | | - forbidden_arg_word = '.' + forbidden_arg_word |
77 | | - if forbidden_arg_word in arg_word: |
78 | | - get_logger().error( |
79 | | - f"CLI argument for param '{forbidden_arg}' is forbidden. Use instead a configuration file." |
80 | | - ) |
81 | | - return False |
| 64 | + # validate args |
| 65 | + is_valid, arg = CliArgs.validate_user_args(args) |
| 66 | + if not is_valid: |
| 67 | + get_logger().error( |
| 68 | + f"CLI argument for param '{arg}' is forbidden. Use instead a configuration file." |
| 69 | + ) |
| 70 | + return False |
| 71 | + |
| 72 | + # Update settings from args |
82 | 73 | args = update_settings_from_args(args) |
83 | 74 |
|
84 | 75 | action = action.lstrip("/").lower() |
|
0 commit comments