Skip to content

Fix/workflow/pr review#1

Open
abelmatos wants to merge 2 commits intomainfrom
fix/workflow/pr-review
Open

Fix/workflow/pr review#1
abelmatos wants to merge 2 commits intomainfrom
fix/workflow/pr-review

Conversation

@abelmatos
Copy link
Owner

@abelmatos abelmatos commented Aug 29, 2025

Summary by CodeRabbit

  • Chores
    • Improved automated PR review workflow to evaluate the merged state of pull requests, yielding more accurate review feedback.
    • Hardened input handling by JSON-encoding titles, bodies, and additional context to prevent formatting and parsing issues in reviews.
    • Enhances reliability and stability of review checks in CI.
    • No impact on application behavior; no user-facing changes.

Signed-off-by: Abel Matos <matos.abel.g+github@gmail.com>
- the Issue Body should be moved to with: instead of env: because of the size limit. 

Signed-off-by: Abel Matos <matos.abel.g+github@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Aug 29, 2025

Walkthrough

Updates the Gemini review workflow to check out the PR’s merge ref and JSON-encode several inputs (title, body, additional context) using toJSON. No other steps or exported entities are changed.

Changes

Cohort / File(s) Summary
Workflow Updates
\.github/workflows/gemini-review.yml
- Checkout uses the PR merge ref instead of default HEAD
- ISSUE_TITLE, ISSUE_BODY, and ADDITIONAL_CONTEXT now wrapped with toJSON(...)
- No other behavioral changes to steps

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant GH as GitHub Actions (PR event)
    participant CO as actions/checkout
    participant GR as Gemini Review Step

    Dev->>GH: Open/Update PR
    GH->>CO: Checkout repository (use PR merge ref)
    note right of CO: Ensures merged state is reviewed
    GH->>GR: Run review with inputs<br/>ISSUE_TITLE, ISSUE_BODY, ADDITIONAL_CONTEXT
    note right of GR: Inputs are JSON-encoded via toJSON(...)
    GR-->>GH: Post review results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble on diffs in the CI glade,
Merge-refs mapped, a precise parade.
Titles and bodies in JSON attire,
Context wrapped neat, just as required.
Thump-thump! says the pipeline’s heart—
A tidy hop to the review’s start. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/workflow/pr-review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/gemini-review.yml (1)

43-44: Make checkout resilient when not running on a PR event

Using the PR merge ref directly will fail if this reusable workflow is invoked without a pull_request/issue (PR) context. Add a safe fallback to github.sha to avoid checkout errors in non‑PR invocations.

-          ref: ${{ format('refs/pull/{0}/merge', github.event.pull_request.number || github.event.issue.number) }}
+          ref: ${{ (github.event.pull_request.number || github.event.issue.number) && format('refs/pull/{0}/merge', github.event.pull_request.number || github.event.issue.number) || github.sha }}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc5c87 and a2c8bbb.

📒 Files selected for processing (1)
  • .github/workflows/gemini-review.yml (1 hunks)

GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
ISSUE_TITLE: '${{ toJSON(github.event.pull_request.title || github.event.issue.title) }}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid JSON-encoding env vars (introduces extra quotes in values)

toJSON(...) wraps the string in quotes and escapes content, so downstream consumers may see literal quotes in the title. Use the raw string instead.

-          ISSUE_TITLE: '${{ toJSON(github.event.pull_request.title || github.event.issue.title) }}'
+          ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ISSUE_TITLE: '${{ toJSON(github.event.pull_request.title || github.event.issue.title) }}'
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
🤖 Prompt for AI Agents
In .github/workflows/gemini-review.yml around line 51, the ISSUE_TITLE is being
set with toJSON(...) which JSON-encodes the title and introduces extra
quotes/escaping; replace the toJSON(...) expression with the raw string
expression (remove toJSON and pass github.event.pull_request.title ||
github.event.issue.title directly) so the environment variable receives the
unquoted title.

ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
ISSUE_TITLE: '${{ toJSON(github.event.pull_request.title || github.event.issue.title) }}'
ISSUE_BODY: '${{ toJSON(github.event.pull_request.body || github.event.issue.body) }}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid JSON-encoding env vars (introduces extra quotes in values)

Same issue for body: JSON-encoding will include surrounding quotes in the env var.

-          ISSUE_BODY: '${{ toJSON(github.event.pull_request.body || github.event.issue.body) }}'
+          ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ISSUE_BODY: '${{ toJSON(github.event.pull_request.body || github.event.issue.body) }}'
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
🤖 Prompt for AI Agents
.github/workflows/gemini-review.yml around line 52: the environment variable
ISSUE_BODY is being set using toJSON(...) which JSON-encodes the string and adds
extra surrounding quotes; remove the toJSON wrapper and set ISSUE_BODY to the
raw expression instead (use ${{ github.event.pull_request.body ||
github.event.issue.body }} ), ensuring you preserve the fallback logic so the PR
body or issue body is used unquoted.

PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
REPOSITORY: '${{ github.repository }}'
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
ADDITIONAL_CONTEXT: '${{ toJSON(inputs.additional_context) }}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid JSON-encoding env vars (introduces extra quotes in values)

Pass additional_context as a plain string; JSON-encoding here is unnecessary and can degrade formatting.

-          ADDITIONAL_CONTEXT: '${{ toJSON(inputs.additional_context) }}'
+          ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ADDITIONAL_CONTEXT: '${{ toJSON(inputs.additional_context) }}'
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
🤖 Prompt for AI Agents
.github/workflows/gemini-review.yml around line 55: the workflow currently sets
ADDITIONAL_CONTEXT using toJSON which JSON-encodes the input and adds extra
quotes/escaping; change it to pass the input directly as a plain string by
removing the toJSON call and assign ADDITIONAL_CONTEXT to the
inputs.additional_context expression so the value is not double-quoted or
escaped.

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

Successfully merging this pull request may close these issues.

1 participant