pr-agent icon indicating copy to clipboard operation
pr-agent copied to clipboard

Improve GitLab pipeline

Open mrT23 opened this issue 11 months ago • 1 comments

Git provider

Gitlab

Issues details

Our current GitLab pipeline guide covers basic capabilities

https://qodo-merge-docs.qodo.ai/installation/gitlab/

Contribtuions from the community to enhance this pipeline would be welcomed.

For example:

  • how to make the bot respond to comments
  • ignore MRs starting by bots
  • other enhancements ...

Image

mrT23 avatar Jan 28 '25 07:01 mrT23

I also came accross an issue that Gitlab code suggestions (like making actual threads) does not working when trying to comment on newly created files:

2025-11-04 11:01:54.314 | ERROR    | pr_agent.git_providers.gitlab_provider:publish_code_suggestions:691 - Could not publish code suggestion:
suggestion: {'body': '**Suggestion:** The `forwardRef` was removed from this component, which breaks its integration with `react-hook-form`\'s `Controller`. The `Controller`\'s `field` prop includes a `ref` that must be passed to the underlying MUI `Select` component for form state management. Re-introduce `forwardRef` to ensure the component can be correctly registered by `react-hook-form`. [possible issue, importance: 9]\n```suggestion\nimport { forwardRef } from \'react\';\nimport FormControl from \'@mui/material/FormControl\';\nimport FormHelperText from \'@mui/material/FormHelperText\';\nimport InputLabel from \'@mui/material/InputLabel\';\nimport Select, { SelectProps } from \'@mui/material/Select\';\n\ntype Props = SelectProps & {\n  helperText?: string;\n};\n\nconst SelectField = forwardRef<HTMLSelectElement, Props>((props: Readonly<Props>, ref) => {\n  const { helperText, ...forwardProps } = props;\n\n  return (\n    <FormControl fullWidth>\n      {forwardProps.label && <InputLabel id="test-select-label">{forwardProps.label}</InputLabel>}\n      <Select {...forwardProps} ref={ref} />\n      {props.helperText && (\n        <FormHelperText error={forwardProps.error} className="select-field-helper-text">\n          {helperText}\n        </FormHelperText>\n      )}\n    </FormControl>\n  );\n});\n```', 'relevant_file': 'portal/src/shared/components/formFields/select-field.tsx', 'relevant_lines_start': 11, 'relevant_lines_end': 25, 'original_suggestion': {'relevant_file': 'portal/src/shared/components/formFields/select-field.tsx\n', 'language': 'typescript\n', 'existing_code': 'const SelectField = (props: Props): React.JSX.Element => {\n  const { helperText, ...forwardProps } = props;\n\n  return (\n    <FormControl fullWidth>\n      {forwardProps.label && <InputLabel id="test-select-label">{forwardProps.label}</InputLabel>}\n      <Select {...forwardProps} />\n      {props.helperText && (\n        <FormHelperText error={forwardProps.error} className="select-field-helper-text">\n          {helperText}\n        </FormHelperText>\n      )}\n    </FormControl>\n  );\n};\n', 'suggestion_content': "The `forwardRef` was removed from this component, which breaks its integration with `react-hook-form`'s `Controller`. The `Controller`'s `field` prop includes a `ref` that must be passed to the underlying MUI `Select` component for form state management. Re-introduce `forwardRef` to ensure the component can be correctly registered by `react-hook-form`.\n", 'improved_code': 'import { forwardRef } from \'react\';\nimport FormControl from \'@mui/material/FormControl\';\nimport FormHelperText from \'@mui/material/FormHelperText\';\nimport InputLabel from \'@mui/material/InputLabel\';\nimport Select, { SelectProps } from \'@mui/material/Select\';\n\ntype Props = SelectProps & {\n  helperText?: string;\n};\n\nconst SelectField = forwardRef<HTMLSelectElement, Props>((props: Readonly<Props>, ref) => {\n  const { helperText, ...forwardProps } = props;\n\n  return (\n    <FormControl fullWidth>\n      {forwardProps.label && <InputLabel id="test-select-label">{forwardProps.label}</InputLabel>}\n      <Select {...forwardProps} ref={ref} />\n      {props.helperText && (\n        <FormHelperText error={forwardProps.error} className="select-field-helper-text">\n          {helperText}\n        </FormHelperText>\n      )}\n    </FormControl>\n  );\n});\n', 'one_sentence_summary': 'Restore `forwardRef` for form integration.\n', 'label': 'possible issue', 'score': 9, 'score_why': 'The suggestion correctly identifies that removing `forwardRef` is a breaking change for integration with `react-hook-form`. The `Controller` component requires the `ref` to be forwarded to the underlying input, and this change restores that critical functionality.\n', 'relevant_lines_start': 11, 'relevant_lines_end': 25}}
error: list index out of range
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/pr_agent/cli.py", line 105, in <module>
    run()
    └ <function run at 0x78d43b2ea980>
  File "/app/pr_agent/cli.py", line 99, in run
    result = asyncio.run(inner())
             │       │   └ <function run.<locals>.inner at 0x78d43b2ea200>
             │       └ <function run at 0x78d444c013a0>
             └ <module 'asyncio' from '/usr/local/lib/python3.12/asyncio/__init__.py'>
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           │      │   └ <coroutine object run.<locals>.inner at 0x78d43b26ab00>
           │      └ <function Runner.run at 0x78d444a71120>
           └ <asyncio.runners.Runner object at 0x78d43b2c7e00>
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           │    │     │                  └ <Task pending name='Task-1' coro=<run.<locals>.inner() running at /app/pr_agent/cli.py:84> wait_for=<Task pending name='Task-...
           │    │     └ <function BaseEventLoop.run_until_complete at 0x78d444a6ed40>
           │    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
           └ <asyncio.runners.Runner object at 0x78d43b2c7e00>
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 678, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x78d444a6eca0>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 645, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x78d444a70ae0>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1999, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x78d444bd2de0>
    └ <Handle Task.task_wakeup(<_GatheringFu...t\n', ...}]}]>)>
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle Task.task_wakeup(<_GatheringFu...t\n', ...}]}]>)>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle Task.task_wakeup(<_GatheringFu...t\n', ...}]}]>)>
    │    └ <member '_context' of 'Handle' objects>
    └ <Handle Task.task_wakeup(<_GatheringFu...t\n', ...}]}]>)>
  File "/app/pr_agent/agent/pr_agent.py", line 123, in handle_request
    return await self._handle_request(pr_url, request, notify)
                 │    │               │       │        └ None
                 │    │               │       └ ['improve']
                 │    │               └ 'https://gitlab.com/whyellow/extern/hertek/sonevo-cloud/merge_requests/4819'
                 │    └ <function PRAgent._handle_request at 0x78d43b2ea840>
                 └ <pr_agent.agent.pr_agent.PRAgent object at 0x78d43e9e5b50>
  File "/app/pr_agent/agent/pr_agent.py", line 116, in _handle_request
    await command2class[action](pr_url, ai_handler=self.ai_handler, args=args).run()
          │             │       │                  │    │                └ []
          │             │       │                  │    └ <class 'pr_agent.algo.ai_handlers.litellm_ai_handler.LiteLLMAIHandler'>
          │             │       │                  └ <pr_agent.agent.pr_agent.PRAgent object at 0x78d43e9e5b50>
          │             │       └ 'https://gitlab.com/whyellow/extern/hertek/sonevo-cloud/merge_requests/4819'
          │             └ 'improve'
          └ {'auto_review': <class 'pr_agent.tools.pr_reviewer.PRReviewer'>, 'answer': <class 'pr_agent.tools.pr_reviewer.PRReviewer'>, '...
  File "/app/pr_agent/tools/pr_code_suggestions.py", line 176, in run
    await self.push_inline_code_suggestions(data)
          │    │                            └ {'code_suggestions': [{'relevant_file': 'portal/src/shared/components/formFields/select-field.tsx\n', 'language': 'typescript...
          │    └ <function PRCodeSuggestions.push_inline_code_suggestions at 0x78d43b2c9440>
          └ <pr_agent.tools.pr_code_suggestions.PRCodeSuggestions object at 0x78d43b122cc0>
  File "/app/pr_agent/tools/pr_code_suggestions.py", line 575, in push_inline_code_suggestions
    is_successful = self.git_provider.publish_code_suggestions(code_suggestions)
                    │    │            │                        └ [{'body': '**Suggestion:** The `forwardRef` was removed from this component, which breaks its integration with `react-hook-fo...
                    │    │            └ <function GitLabProvider.publish_code_suggestions at 0x78d43b2b09a0>
                    │    └ <pr_agent.git_providers.gitlab_provider.GitLabProvider object at 0x78d43b1f1880>
                    └ <pr_agent.tools.pr_code_suggestions.PRCodeSuggestions object at 0x78d43b122cc0>
> File "/app/pr_agent/git_providers/gitlab_provider.py", line 678, in publish_code_suggestions
    relevant_line_in_file = lines[relevant_lines_start - 1]
                            │     └ 11
                            └ []

martijndormans avatar Nov 04 '25 12:11 martijndormans