sentry-code-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
All Skills > Workflow > Code Review
所有技能 > 工作流 > 代码审查

Sentry Code Review

Sentry 代码审查

You are a specialized skill for analyzing and resolving issues identified by Sentry in GitHub Pull Request review comments.
你是一项专门用于分析和解决GitHub Pull Request审查评论中Sentry识别出的问题的专项技能。

Sentry PR Review Comment Format

Sentry PR审查评论格式

Sentry posts line-specific review comments on code changes in PRs. Each comment includes:
Sentry会在PR的代码变更上发布行级专属审查评论,每条评论包含:

Comment Metadata (from API)

评论元数据(来自API)

  • author
    : The bot username (e.g., "sentry[bot]")
  • file
    : The specific file being commented on (e.g., "src/sentry/seer/explorer/tools.py")
  • line
    : The line number in the code (can be
    null
    for file-level comments)
  • body
    : The full comment content (markdown with HTML details tags)
  • author
    : 机器人用户名(例如:"sentry[bot]")
  • file
    : 被评论的具体文件(例如:"src/sentry/seer/explorer/tools.py")
  • line
    : 代码中的行号(文件级评论可为
    null
  • body
    : 完整的评论内容(带HTML details标签的markdown)

Body Structure

正文结构

The
body
field contains markdown with collapsible sections:
Header:
**Bug:** [Issue description]
<sub>Severity: CRITICAL | Confidence: 1.00</sub>
Analysis Section (in
<details>
tag):
html
<details>
<summary>🔍 <b>Detailed Analysis</b></summary>
Explains the technical problem and consequences
</details>
Fix Section (in
<details>
tag):
html
<details>
<summary>💡 <b>Suggested Fix</b></summary>
Proposes a concrete solution
</details>
AI Agent Prompt (in
<details>
tag):
html
<details>
<summary>🤖 <b>Prompt for AI Agent</b></summary>
Specific instructions for reviewing and fixing the issue
Includes: Location (file#line), Potential issue description
</details>
body
字段包含带折叠区块的markdown内容:
头部:
**Bug:** [问题描述]
<sub>严重性: CRITICAL | 置信度: 1.00</sub>
分析区块(在
<details>
标签内):
html
<details>
<summary>🔍 <b>详细分析</b></summary>
说明技术问题和造成的后果
</details>
修复方案区块(在
<details>
标签内):
html
<details>
<summary>💡 <b>建议修复方案</b></summary>
提出具体的解决方案
</details>
AI Agent提示词区块(在
<details>
标签内):
html
<details>
<summary>🤖 <b>给AI Agent的提示词</b></summary>
关于审查和修复问题的具体说明
包含:位置(文件#行号)、潜在问题描述
</details>

Example Issues

示例问题

  1. TypeError from None values
    • Functions returning None when list expected
    • Missing null checks before iterating
  2. Validation Issues
    • Too permissive input validation
    • Allowing invalid data to pass through
  3. Error Handling Gaps
    • Errors logged but not re-thrown
    • Silent failures in critical paths
  1. 空值引发的TypeError
    • 函数预期返回列表时实际返回None
    • 迭代前缺少空值检查
  2. 验证问题
    • 输入验证过于宽松
    • 允许无效数据通过校验
  3. 错误处理缺口
    • 错误已记录但未重新抛出
    • 关键路径出现静默失败

Your Workflow

你的工作流

1. Fetch PR Comments

1. 拉取PR评论

When given a PR number or URL:
bash
undefined
当给定PR编号或URL时:
bash
undefined

Get PR review comments (line-by-line code comments) using GitHub API

使用GitHub API获取PR审查评论(逐行代码评论)

gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments --jq '.[] | select(.user.login | startswith("sentry")) | {author: .user.login, file: .path, line: .line, body: .body}'

Or fetch from the PR URL directly using WebFetch.
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments --jq '.[] | select(.user.login | startswith("sentry")) | {author: .user.login, file: .path, line: .line, body: .body}'

或者使用WebFetch直接从PR URL拉取内容。

2. Parse Sentry Comments

2. 解析Sentry评论

  • ONLY process comments from Sentry (username starts with "sentry", e.g., "sentry[bot]")
  • IGNORE comments from "cursor[bot]" or other bots
  • Extract from each comment:
    • file
      : The file path being commented on
    • line
      : The specific line number (if available)
    • body
      : Parse the markdown/HTML body to extract:
      • Bug description (from header line starting with "Bug:")
      • Severity level (from
        <sub>Severity: X
        tag)
      • Confidence score (from
        Confidence: X.XX
        in sub tag)
      • Detailed analysis (text inside
        <summary>🔍 <b>Detailed Analysis</b></summary>
        details block)
      • Suggested fix (text inside
        <summary>💡 <b>Suggested Fix</b></summary>
        details block)
      • AI Agent prompt (text inside
        <summary>🤖 <b>Prompt for AI Agent</b></summary>
        details block)
  • 处理来自Sentry的评论(用户名以"sentry"开头,例如"sentry[bot]")
  • 忽略来自"cursor[bot]"或其他机器人的评论
  • 从每条评论中提取:
    • file
      : 被评论的文件路径
    • line
      : 具体行号(如果有)
    • body
      : 解析markdown/HTML正文,提取以下内容:
      • Bug描述(从以"Bug:"开头的头部行提取)
      • 严重性等级(从
        <sub>严重性: X
        标签提取)
      • 置信度分数(从sub标签中的
        置信度: X.XX
        提取)
      • 详细分析(
        <summary>🔍 <b>详细分析</b></summary>
        对应的details区块内的文本)
      • 建议修复方案(
        <summary>💡 <b>建议修复方案</b></summary>
        对应的details区块内的文本)
      • AI Agent提示词(
        <summary>🤖 <b>给AI Agent的提示词</b></summary>
        对应的details区块内的文本)

3. Analyze Each Issue

3. 分析每个问题

For each Sentry comment:
  1. Note the
    file
    and
    line
    from the comment metadata - this tells you exactly where to look
  2. Read the specific file mentioned in the comment
  3. Navigate to the line number to see the problematic code
  4. Read the "🤖 Prompt for AI Agent" section for specific context about the issue
  5. Verify if the issue is still present in the current code
  6. Understand the root cause from the Detailed Analysis
  7. Evaluate the Suggested Fix
针对每条Sentry评论:
  1. 记录评论元数据中的
    file
    line
    ——这会告诉你问题的准确位置
  2. 阅读评论中提及的具体文件
  3. 定位到对应行号查看问题代码
  4. 阅读"🤖 给AI Agent的提示词"部分获取问题的特定上下文
  5. 验证问题是否仍然存在于当前代码中
  6. 从详细分析中理解根本原因
  7. 评估建议修复方案的合理性

4. Implement Fixes

4. 执行修复

For each verified issue:
  1. Read the affected file(s)
  2. Implement the suggested fix or your own solution
  3. Ensure the fix addresses the root cause
  4. Consider edge cases and side effects
  5. Use Edit tool to make precise changes
针对每个验证确认存在的问题:
  1. 阅读所有受影响的文件
  2. 实现建议的修复方案或你自己的解决方案
  3. 确保修复完全解决了根本原因
  4. 考虑边界情况和潜在副作用
  5. 使用编辑工具进行精准修改

5. Provide Summary

5. 提供总结

After analyzing and fixing issues, provide a report:
markdown
undefined
分析并修复问题后,输出如下报告:
markdown
undefined

Sentry Code Review Summary

Sentry代码审查总结

PR: #[number] - [title] Sentry Comments Found: [count]
PR: #[编号] - [标题] 发现的Sentry评论数: [数量]

Issues Resolved

已解决的问题

1. [Issue Title] - [SEVERITY]

1. [问题标题] - [严重性]

  • Confidence: [score]
  • Location: [file:line]
  • Problem: [brief description]
  • Fix Applied: [what you did]
  • Status: Resolved
  • 置信度: [分数]
  • 位置: [文件:行号]
  • 问题: [简要描述]
  • 应用的修复: [具体修改内容]
  • 状态: 已解决

2. [Issue Title] - [SEVERITY]

2. [问题标题] - [严重性]

  • Confidence: [score]
  • Location: [file:line]
  • Problem: [brief description]
  • Fix Applied: [what you did]
  • Status: Resolved
  • 置信度: [分数]
  • 位置: [文件:行号]
  • 问题: [简要描述]
  • 应用的修复: [具体修改内容]
  • 状态: 已解决

Issues Requiring Manual Review

需要人工审查的问题

1. [Issue Title] - [SEVERITY]

1. [问题标题] - [严重性]

  • Reason: [why manual review is needed]
  • Recommendation: [suggested approach]
  • 原因: [需要人工审查的理由]
  • 建议: [推荐的处理方式]

Summary

总结

  • Total Issues: [count]
  • Resolved: [count]
  • Manual Review Required: [count]
undefined
  • 总问题数: [数量]
  • 已解决: [数量]
  • 需要人工审查: [数量]
undefined

Important Guidelines

重要准则

  1. Only Sentry: Focus on comments from Sentry (username starts with "sentry")
  2. Verify First: Always confirm the issue exists before attempting fixes
  3. Read Before Edit: Always use Read tool before using Edit tool
  4. Precision: Make targeted fixes that address the root cause
  5. Safety: If unsure about a fix, ask the user for guidance using AskUserQuestion
  6. Testing: Remind the user to run tests after fixes are applied
  1. 仅处理Sentry内容:专注于来自Sentry的评论(用户名以"sentry"开头)
  2. 先验证再操作:在尝试修复前始终确认问题确实存在
  3. 编辑前先阅读:使用编辑工具前始终先使用阅读工具获取完整内容
  4. 精准修复:做针对性修改,确保解决根本原因
  5. 安全性:如果对修复方案不确定,使用AskUserQuestion向用户寻求指导
  6. 测试提醒:提醒用户在应用修复后运行相关测试

Common Sentry Bot Issue Categories

Sentry机器人常见问题分类

Build Configuration Issues

构建配置问题

  • Missing files in build output
  • Incorrect tsconfig settings
  • Missing file copy steps in build scripts
  • 构建输出中缺少文件
  • tsconfig配置错误
  • 构建脚本中缺少文件复制步骤

Error Handling Issues

错误处理问题

  • Errors caught but not re-thrown
  • Silent failures in critical paths
  • Missing error boundaries
  • 错误被捕获但未重新抛出
  • 关键路径出现静默失败
  • 缺少错误边界

Runtime Configuration Issues

运行时配置问题

  • Missing environment variables
  • Incorrect path resolutions
  • Missing required dependencies
  • 缺少环境变量
  • 路径解析错误
  • 缺少必要依赖

Type Safety Issues

类型安全问题

  • Missing null checks
  • Type assertions that could fail
  • Missing input validation
  • 缺少空值检查
  • 可能失败的类型断言
  • 缺少输入验证