Skip to content

fix: gate adr-required 索引分支 python 缩进错误(.github #164 回归,ADR-0021/0053) - #210

Closed
randypanding wants to merge 2 commits into
mainfrom
fix/gate-adr-index-indent
Closed

fix: gate adr-required 索引分支 python 缩进错误(.github #164 回归,ADR-0021/0053)#210
randypanding wants to merge 2 commits into
mainfrom
fix/gate-adr-index-indent

Conversation

@randypanding

Copy link
Copy Markdown
Contributor

#164 归档迁移新加的 INDEX.yaml 分支中 python3 -c 多行带缩进——首跑即 IndentationError,阻断全部 C1 PR(PR#209 实例)。改单行 python3 -c(YAML 块缩进与 python 零缩进两难的正解)。本地 YAML+全步骤 bash -n 预检过。

注意:本 PR 与 PR#209(cost-check infra 恢复通道)都依赖此修复解锁。

…全部 C1 PR)——改单行形式(YAML 块缩进与 python 零缩进两难)——ADR-0021/0053
Copilot AI lite review requested due to automatic review settings August 21, 2026 14:45
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@randypanding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Limit details: You’ve used all 10 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 975842f3-c8a1-44bf-ab4a-20a244298247

📥 Commits

Reviewing files that changed from the base of the PR and between ccf176a and 53c121b.

📒 Files selected for processing (1)
  • .github/workflows/gate.yml

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix gate ADR index step: avoid python3 -c IndentationError regression

🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Replace multi-line python3 -c with one-line form to prevent YAML-indentation IndentationError.
• Keep ADR INDEX.yaml parsing behavior unchanged while restoring fail-closed gating.
• Unblock adr-required gate and downstream CI workflows dependent on ADR mapping output.
Diagram

graph TD
  wf[".github/workflows/gate.yml"] --> step["ADR index mapping"] --> py["python3 -c (one-line)"] --> map["/tmp/adr_map.txt"]
  map --> chk{"Map non-empty?"}
  chk -- "no" --> fail["Fail closed"]
  chk -- "yes" --> next["Next gate steps"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract the inline Python into a tracked script file
  • ➕ Improves readability and maintainability vs a dense one-liner
  • ➕ Enables adding tests or local execution easily
  • ➕ Avoids future YAML quoting/indent pitfalls
  • ➖ Slightly larger change footprint (new file + wiring) for what is currently a hotfix
  • ➖ Requires deciding script location/ownership conventions
2. Use a YAML CLI tool (e.g., yq) instead of Python
  • ➕ Simplifies workflow steps to declarative CLI invocations
  • ➕ Potentially reduces quoting complexity
  • ➖ Introduces or depends on a tool that may not be preinstalled
  • ➖ Version/behavior differences across yq variants can create fragility

Recommendation: For an urgent regression fix in a gating workflow, the PR’s approach (switch to a one-line python3 -c) is the minimal, lowest-risk change that restores execution without changing the intended logic. Consider a follow-up to extract the snippet into a repo script if readability or future edits become a concern.

Files changed (1) +1 / -7

Bug fix (1) +1 / -7
gate.ymlFix inline Python indent failure by converting to one-line 'python3 -c' +1/-7

Fix inline Python indent failure by converting to one-line 'python3 -c'

• Replaces an indented multi-line 'python3 -c' block with an equivalent single-line command to avoid 'IndentationError' caused by YAML block indentation. Keeps the INDEX.yaml parsing output (number + archive_path mapping) and the fail-closed behavior intact.

.github/workflows/gate.yml

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the adr-required gate in gate.yml to avoid a Python IndentationError introduced when parsing the new decisions/INDEX.yaml “index world” branch, unblocking C1-path PRs that rely on this check.

Changes:

  • Replaces the multi-line python3 -c snippet (susceptible to YAML indentation issues) with a single-line invocation to generate /tmp/adr_map.txt from INDEX.yaml.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/gate.yml Outdated
p = e.get("archive_path")
if p:
print(f"{int(e[\"number\"]):04d} {p}")' >/tmp/adr_map.txt
python3 -c 'import yaml;d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8"));[print(f"{int(e[\"number\"]):04d} {e[\"archive_path\"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' >/tmp/adr_map.txt
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Invalid Python escaping 🐞 Bug ≡ Correctness
Description
The new python3 -c one-liner contains e[\"number\"] / e[\"archive_path\"], but because the
whole command is Bash single-quoted, the backslashes are passed through literally and produce
invalid Python syntax, breaking the workflow at runtime.
Code

.github/workflows/gate.yml[173]

+            python3 -c 'import yaml;d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8"));[print(f"{int(e[\"number\"]):04d} {e[\"archive_path\"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' >/tmp/adr_map.txt
Relevance

●●● Strong

Deterministic runtime syntax bug in newly added command; team accepts fixing such bugs before merge.

PR-#61

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR changes the workflow to a single-line python3 -c command, but the literal \" sequences
are part of the Python source passed to -c because the command is Bash single-quoted. In Python
source, \" outside a string literal is invalid, so this line will fail at runtime.

.github/workflows/gate.yml[170-176]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The `python3 -c '...'` string is enclosed in Bash single quotes, so `\"` is not unescaped by the shell. Python receives source containing `e[\"number\"]`, which is invalid syntax and will raise `SyntaxError` before producing `/tmp/adr_map.txt`.

### Issue Context
This step is part of the ADR index-world gating logic. A runtime failure here will cause `adr_map.txt` to be empty/missing and the job to fail (blocking all C1 PRs).

### Fix Focus Areas
- .github/workflows/gate.yml[173-173]

### Suggested change
Replace the escaped quotes with normal Python dict-key syntax (double quotes are safe inside Bash single quotes), and optionally harden `safe_load` output:

```bash
python3 -c 'import yaml; d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8")) or {}; [print(f"{int(e["number"]):04d} {e["archive_path"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' > /tmp/adr_map.txt
```

Even cleaner (avoid nested quoting entirely) is to switch the f-string to single-quoted dict keys:

```bash
python3 -c 'import yaml; d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8")) or {}; [print(f"{int(e['"'"'number'"'"']):04d} {e['"'"'archive_path'"'"']}") for e in (d.get("entries") or []) if e.get("archive_path")]' > /tmp/adr_map.txt
```

(Or keep double-quoted keys and remove all backslashes, which is simplest.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Card: line missing 📘 Rule violation § Compliance
Description
This PR modifies .github/workflows/gate.yml, but the PR description body does not include the
required single Card: <owner>/<repo>#<n> metadata line. Downstream automation that parses card
metadata may fail or be unable to link this change to a tracked work item.
Code

.github/workflows/gate.yml[173]

+            python3 -c 'import yaml;d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8"));[print(f"{int(e[\"number\"]):04d} {e[\"archive_path\"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' >/tmp/adr_map.txt
Relevance

●●● Strong

Active compliance rule requires a Card metadata line; PR description lacks it, so flagged and fixed.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2825427 requires exactly one Card: metadata line in the PR description; the
provided PR description text contains no such line, so the requirement is not met.

Rule 2825427: Require PR description to include a card metadata line


Grey Divider

Context sources
✅ Compliance rules (platform): 17 rules
Review mode: ⚖️ Balanced: This is a localized but behavior-changing CI workflow fix in a gate that blocks PRs; a careful single-pass review should verify shell/YAML/Python quoting and fail-closed behavior.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display preferences with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread .github/workflows/gate.yml Outdated
p = e.get("archive_path")
if p:
print(f"{int(e[\"number\"]):04d} {p}")' >/tmp/adr_map.txt
python3 -c 'import yaml;d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8"));[print(f"{int(e[\"number\"]):04d} {e[\"archive_path\"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' >/tmp/adr_map.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. card: line missing 📘 Rule violation § Compliance

This PR modifies .github/workflows/gate.yml, but the PR description body does not include the
required single Card: <owner>/<repo>#<n> metadata line. Downstream automation that parses card
metadata may fail or be unable to link this change to a tracked work item.

Comment thread .github/workflows/gate.yml Outdated
p = e.get("archive_path")
if p:
print(f"{int(e[\"number\"]):04d} {p}")' >/tmp/adr_map.txt
python3 -c 'import yaml;d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8"));[print(f"{int(e[\"number\"]):04d} {e[\"archive_path\"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' >/tmp/adr_map.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Invalid python escaping 🐞 Bug ≡ Correctness

The new python3 -c one-liner contains e[\"number\"] / e[\"archive_path\"], but because the
whole command is Bash single-quoted, the backslashes are passed through literally and produce
invalid Python syntax, breaking the workflow at runtime.
Agent Prompt
### Issue description
The `python3 -c '...'` string is enclosed in Bash single quotes, so `\"` is not unescaped by the shell. Python receives source containing `e[\"number\"]`, which is invalid syntax and will raise `SyntaxError` before producing `/tmp/adr_map.txt`.

### Issue Context
This step is part of the ADR index-world gating logic. A runtime failure here will cause `adr_map.txt` to be empty/missing and the job to fail (blocking all C1 PRs).

### Fix Focus Areas
- .github/workflows/gate.yml[173-173]

### Suggested change
Replace the escaped quotes with normal Python dict-key syntax (double quotes are safe inside Bash single quotes), and optionally harden `safe_load` output:

```bash
python3 -c 'import yaml; d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8")) or {}; [print(f"{int(e["number"]):04d} {e["archive_path"]}") for e in (d.get("entries") or []) if e.get("archive_path")]' > /tmp/adr_map.txt
```

Even cleaner (avoid nested quoting entirely) is to switch the f-string to single-quoted dict keys:

```bash
python3 -c 'import yaml; d=yaml.safe_load(open("/tmp/adr_index.yaml",encoding="utf-8")) or {}; [print(f"{int(e['"'"'number'"'"']):04d} {e['"'"'archive_path'"'"']}") for e in (d.get("entries") or []) if e.get("archive_path")]' > /tmp/adr_map.txt
```

(Or keep double-quoted keys and remove all backslashes, which is simplest.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@randypanding

Copy link
Copy Markdown
Contributor Author

被 main 上的等价修复取代(scripts/adr_index_map.py 抽取方案更优)。关闭。

@randypanding
randypanding deleted the fix/gate-adr-index-indent branch August 21, 2026 14:52
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.

2 participants