When pg-minify fails, it's hard to locate the issue
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- postgresql, typescript
調査の方向性
まず dist/commands/watch.js を読み、特に現在のマイグレーションを処理する pg-minify の呼び出しを確認して、報告されている current/12000-insert_iso3166_countries.sql の再現を実行します。マイグレーションファイルの境界とパーサーの行番号がどのように組み立てられているかを追跡します。完了の条件は、pg-minify の失敗によって元のエラーを保持したまま、該当するファイルとおおよその行が特定されることです。
索引モデルが issue の本文から書いたものです。
説明
Summary
When pg-minify fails, Graphile Migrate outputs pg-minify's error, but doesn't relate it to the file that actually caused the problem. This is particularly problematic if you have a large (e.g. initial) migration and you're using the current/ folder - you don't know which file the error occurred in.
Steps to reproduce
current/12000-insert_iso3166_countries.sql:
COPY countries (name, alpha_2, code) FROM stdin DELIMITER '|';
Kyrgyzstan|KG|417
Lao People's Democratic Republic|LA|418
Latvia|LV|428
\.
Expected results
Error on line 3 of 12000-insert_iso3166_countries.sql (we don't support COPY syntax).
Actual results
🛑 Error occurred whilst processing migration
SQLParsingError: Error parsing SQL at {line:24153,col:11}: Unclosed text block.
Additional context
graphile-migrate 1.0.1; linux; current/ folder.
Possible Solution
The following mod to dist/commands/watch.js gives more information:
let currentBodyMinified;
try {
currentBodyMinified = pgMinify(currentBodyFromDryRun);
} catch (e) {
const matches = e.message.match(/Error parsing SQL at \{line:(\d+),col:(\d+)\}/);
if (matches) {
const [_, ln, col] = matches;
const lines = currentBodyFromDryRun.split("\n");
const leadingLines = lines.slice(0, +ln);
const lastSplit = [...leadingLines].reverse().find(l => l.match(/^--! split/));
let filename = null;
let offset = 0;
if (lastSplit) {
filename = lastSplit.split(':')[1].trim();
const index = leadingLines.indexOf(lastSplit);
offset = index + 1;
}
const previousLine = lines[+ln - 2];
const line = lines[+ln - 1];
const nextLine = lines[+ln];
const details = filename ? `current/${filename} line ${+ln - offset}-ish` : `current.sql line ${ln}-ish`
console.error(`Error happened around here ${details}:`);
console.error();
console.error(previousLine || "");
console.error(line || "");
console.error("-".repeat(+col - 1) + "^");
console.error(nextLine || "");
}
throw e;
}
produces:
Error happened around here current/12000-insert_iso3166_countries.sql line 3-ish:
Kyrgyzstan|KG|417
Lao People's Democratic Republic|LA|418
----------^
Latvia|LV|428
🛑 Error occurred whilst processing migration
SQLParsingError: Error parsing SQL at {line:24153,col:11}: Unclosed text block.
- 主要言語
- TypeScript
- スター
- 836
- フォーク
- 71
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphile/migrate のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
🐛 bug
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
graphile/migrate の issue をすべて見る
似ている issue
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsオープンbug triage:owned
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
directus/directus#28558 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
review: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
1lck/Lithe-IDEA#2432 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
cloudflare/workers-sdk#17189 ·
メンテナーはふだん 1 日以内に返信