Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Auto Approve Not Working in PR Agent #1482

Open
PoMaH07 opened this issue Jan 24, 2025 · 0 comments
Open

Issue: Auto Approve Not Working in PR Agent #1482

PoMaH07 opened this issue Jan 24, 2025 · 0 comments

Comments

@PoMaH07
Copy link

PoMaH07 commented Jan 24, 2025

Summary

The auto-approve feature of PR Agent is not functioning as expected despite being configured in the .pr_agent.toml file and executed through GitLab CI. The main goal is to enable auto-approval based on predefined criteria.


Steps to Reproduce

  1. Set up the .pr_agent.toml file with the following configuration:
    [pr_reviewer]
    require_tests_review = true
    require_security_review = true
    require_estimate_effort_to_review = true
    ask_and_reflect = false
    final_update_message = true
    require_score_review = false
    
    persistent_comment = false
    inline_code_comments = false
    enable_review_labels_effort = true
    enable_review_labels_security = true
    enable_auto_approval = true
    
    [pr_code_suggestions]
    demand_code_suggestions_self_review = true
    approve_pr_on_self_review = true
    focus_only_on_problems = true
    commitable_code_suggestions = true
    apply_suggestions_checkbox = true
    summarize = true
  2. Place the .pr_agent.toml file in the develop branch of the repository.
  3. Execute the GitLab CI pipeline with the following job configuration:
    pr_agent_job:
      stage: pr_agent
      image:
        name: codiumai/pr-agent:latest
        entrypoint: [""]
      script:
        - cd /app
        - echo "Running PR Agent action step"
        - export MR_URL="$CI_MERGE_REQUEST_PROJECT_URL/merge_requests/$CI_MERGE_REQUEST_IID"
        - echo "MR_URL=$MR_URL"
        - export gitlab__url=$CI_SERVER_PROTOCOL://$CI_SERVER_FQDN
        - export gitlab__PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN
        - export config__git_provider="gitlab"
        - export openai__key=$OPENAI_KEY
        - python -m pr_agent.cli --pr_url="$MR_URL" describe
        - python -m pr_agent.cli --pr_url="$MR_URL" review auto_approve --pr_reviewer.require_score_review=true --pr_reviewer.enable_review_labels_effort=true --pr_reviewer.require_security_review=true --best_practices.enable_global_best_practices=true
        - python -m pr_agent.cli --pr_url="$MR_URL" improve --config.output_relevant_configurations=true
  4. Observe the logs and behavior of the PR Agent.

Observed Behavior

  1. The following log message indicates that the auto-approval feature is disabled:
    2025-01-23 14:26:15.765 | INFO     | pr_agent.tools.pr_reviewer:run:126 - Auto approve flow PR: https://gitlab ...
    2025-01-23 14:26:15.767 | INFO     | pr_agent.tools.pr_reviewer:auto_approve_logic:410 - Auto-approval option is disabled
    
  2. The approve_pr_on_self_review setting does not approve the PR even when the checkbox "I am familiar with the suggestions" is selected.
  3. The apply_suggestions_checkbox setting does not add the expected checkbox for applying suggestions.
  4. The commitable_code_suggestions setting works correctly, allowing immediate commits of suggestions.
  5. The --config.output_relevant_configurations=true flag does not output the configuration applied during the improve step.

Expected Behavior

  1. The auto-approval feature should work when enable_auto_approval = true is set in .pr_agent.toml.
  2. The approve_pr_on_self_review setting should approve the PR when the self-review checkbox is selected.
  3. The apply_suggestions_checkbox setting should add the expected checkbox in the interface.
  4. The --config.output_relevant_configurations=true flag should output the effective configuration applied during the process.

Additional Context

  • The .pr_agent.toml file is located in the develop branch of the repository.
  • The team uses GitLab as the primary Git provider.

Request for Assistance

Please advise on:

  1. Why the enable_auto_approval setting is not being respected despite being set to true.
  2. Any additional steps or configurations required to enable auto-approval functionality.
  3. Debugging steps to determine why specific settings (e.g., approve_pr_on_self_review, apply_suggestions_checkbox) are not functioning as expected.
  4. How to ensure that --config.output_relevant_configurations=true outputs the correct configuration during the CI pipeline run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant