fix: gate adr-required 索引分支 python 缩进错误(.github #164 回归,ADR-0021/0053) - #210
fix: gate adr-required 索引分支 python 缩进错误(.github #164 回归,ADR-0021/0053)#210randypanding wants to merge 2 commits into
Conversation
…全部 C1 PR)——改单行形式(YAML 块缩进与 python 零缩进两难)——ADR-0021/0053
|
Warning Review limit reached
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. How can I continue?Wait for the limit to reset, then comment 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
PR Summary by QodoFix gate ADR index step: avoid python3 -c IndentationError regression
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
There was a problem hiding this comment.
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 -csnippet (susceptible to YAML indentation issues) with a single-line invocation to generate/tmp/adr_map.txtfromINDEX.yaml.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| 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 |
…ror;本地 3.11 构造 INDEX 实测含空 archive_path 跳过语义)
Code Review by Qodo
1. Invalid Python escaping
|
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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
|
被 main 上的等价修复取代(scripts/adr_index_map.py 抽取方案更优)。关闭。 |
#164 归档迁移新加的 INDEX.yaml 分支中 python3 -c 多行带缩进——首跑即 IndentationError,阻断全部 C1 PR(PR#209 实例)。改单行 python3 -c(YAML 块缩进与 python 零缩进两难的正解)。本地 YAML+全步骤 bash -n 预检过。
注意:本 PR 与 PR#209(cost-check infra 恢复通道)都依赖此修复解锁。