When pg-minify fails, it's hard to locate the issue
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- postgresql, typescript
Hướng nghiên cứu
Bắt đầu bằng cách đọc dist/commands/watch.js, đặc biệt là lệnh gọi pg-minify xử lý các migration hiện tại, và chạy bản tái hiện được báo cáo của current/12000-insert_iso3166_countries.sql. Theo dõi cách ranh giới của các tệp migration và số dòng của parser được ghép lại; hoàn tất khi lỗi pg-minify xác định được tệp chịu trách nhiệm và dòng gần đúng, đồng thời giữ nguyên lỗi ban đầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 836
- Fork
- 71
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphile/migrate
-
Partition migrations folderĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
🐛 bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
Tất cả issue của graphile/migrate
Issue tương tự
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsĐang mởbug triage:owned
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
directus/directus#28558 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
review: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
1lck/Lithe-IDEA#2432 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
cloudflare/workers-sdk#17189 ·
Maintainer thường phản hồi trong vòng 1 ngày