guanghulab/brain/dev-experience/error-patterns.json
2026-05-10 13:12:44 +08:00

96 lines
4.2 KiB
JSON
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"_meta": {
"name": "铸渊错题本",
"version": "1.0",
"copyright": "国作登字-2026-A-00037559",
"description": "记录反复出错的模式 · 自动预警 · 每次开发前必查",
"created": "2026-03-31T03:34:00Z",
"last_updated": "2026-03-31T03:34:00Z"
},
"alert_rules": {
"high_frequency_threshold": 3,
"high_frequency_message": "⚠️ 此错误已出现{count}次 · 每一步都要多验证",
"recent_threshold_days": 7,
"recent_message": "🔴 最近7天内刚犯过此错误 · 务必警惕"
},
"total_patterns": 3,
"patterns": [
{
"id": "ERR-001",
"pattern": "set -e + grep无匹配 = 静默退出",
"category": "bash-scripting",
"severity": "high",
"occurrence_count": 1,
"first_seen": "2026-03-31",
"last_seen": "2026-03-31",
"description": "在bash脚本中使用set -euo pipefail时如果grep命令没有匹配到任何行grep返回exit code 1。配合pipefail整个pipeline的退出码变为1导致set -e触发脚本静默退出——没有任何错误信息输出。",
"trigger_conditions": [
"脚本使用 set -e 或 set -euo pipefail",
"pipeline中使用grep但目标字符串可能不存在",
"awk/sed后面跟的grep可能无匹配"
],
"prevention": [
"在grep命令后添加 || true",
"改用手动错误处理替代set -e",
"使用grep -c统计匹配数而非直接grep",
"将grep结果先存变量再判断是否为空"
],
"code_example": {
"wrong": "RESULT=$(echo \"$DATA\" | grep \"pattern\" | awk '{print $3}')",
"right": "RESULT=$(echo \"$DATA\" | grep \"pattern\" | awk '{print $3}') || true"
},
"related_experiences": ["EXP-20260331-001"],
"risk_level": "⚠️ 高频陷阱 · 每次写bash脚本时检查"
},
{
"id": "ERR-002",
"pattern": "openssl text · ",
"category": "cryptography",
"severity": "medium",
"occurrence_count": 1,
"first_seen": "2026-03-31",
"last_seen": "2026-03-31",
"description": "使openssl pkey -text -nooutgrep+tropenssl",
"trigger_conditions": [
"使openssl pkey -text -noout",
"grep -Atail",
"(tail -4)"
],
"prevention": [
"使DER: openssl pkey -outform DER | tail -c <>",
"base64",
"text"
],
"code_example": {
"wrong": "openssl pkey -text -noout | grep -A5 priv: | tail -4 | tr -d ' :\\n' | head -c 43",
"right": "openssl pkey -outform DER | tail -c 32 | base64 | tr '+/' '-_' | tr -d '='"
},
"related_experiences": ["EXP-20260331-001"],
"risk_level": " · DER"
},
{
"id": "ERR-003",
"pattern": "",
"category": "compatibility",
"severity": "medium",
"occurrence_count": 1,
"first_seen": "2026-03-31",
"last_seen": "2026-03-31",
"description": "CLI(xrayopensslnode)退",
"trigger_conditions": [
"CLIstdout(grep/awk/sed)",
"CLI",
"使latest"
],
"prevention": [
"使(grep -i)",
"退",
"stdoutstderr",
"()"
],
"related_experiences": ["EXP-20260331-001"],
"risk_level": " · CLI"
}
]
}