-
Notifications
You must be signed in to change notification settings - Fork 4
Implement goccy/go-yaml with line offset support for frontmatter error reporting #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@copilot do not try to unwrap the goccy error, send it directly to the output. |
This change addresses @pelikhan's feedback to not unwrap goccy errors but send them directly to output. Instead of using reflection to extract from goccy error structure, we now parse the [line:column] format directly from the goccy error message string. Benefits: - More direct approach using goccy error messages as-is - Eliminates complex reflection-based error extraction - Provides precise location information (e.g., 6:10 instead of 1:1) - Better error messages from goccy library Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done. I've removed the error unwrapping logic and now parse the goccy error message format directly using the The change is in commit 08d7228. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot add extensive test suite of frontmatter scripts with syntax errors |
- Created comprehensive test suite for frontmatter YAML syntax errors - Added 16 different syntax error scenarios with precise error location testing - Includes boundary conditions, edge cases, and real-world error examples - Tests goccy/go-yaml's native [line:column] error format parsing - Validates error message formatting and console output integration - Covers unicode content, deeply nested structures, and complex YAML errors - Ensures precise error reporting for improved debugging experience Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added comprehensive frontmatter syntax error test suite with 16+ different error scenarios, including:
The tests validate goccy/go-yaml's precise Added in commit 2f59753. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot make sure that error line numbers take into account the leading --- line of the frontmatter . It should take line offset as parameter as document may have multiple frontmatter entries in future versions. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated the Key changes:
The error reporting now correctly shows line 3 for the syntax error in the frontmatter content, properly accounting for the document structure. Implemented in commit a378062. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…te expected output formatting in tests for consistency
…st 2; update expected output formatting in tests for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot do not try
Bette yaml errors with error location |
This PR replaces
gopkg.in/yaml.v3
withgithub.com/goccy/go-yaml
to provide precise YAML error location information and adds support for frontmatter line offset calculation to handle documents with multiple frontmatter entries.Problem
Previously, YAML syntax errors in frontmatter would either:
1,1
coordinates when location information was unavailableSolution
Enhanced YAML Error Parsing with Line Offset Support:
The implementation leverages goccy/go-yaml's native error message format by parsing the
[line:column]
pattern directly from error strings, with proper line offset calculation for frontmatter position.Improved Error Location Calculation:
Updated to use the formula
yamlLine + frontmatterLineOffset - 1
to properly handle:---
line of frontmatterComprehensive Test Coverage:
Added extensive test suite covering 16+ different YAML syntax error scenarios with various frontmatter offset positions.
Key Changes
github.com/goccy/go-yaml@v1.18.0
ExtractYAMLError
now acceptsfrontmatterLineOffset
FrontmatterResult.FrontmatterStart
from parser---
line in calculationsImpact
Before:
After:
The error now correctly points to line 3 where the syntax error occurs, properly accounting for the frontmatter's position in the document and the leading
---
line. This enables accurate error reporting regardless of where frontmatter appears in the document.Fixes #100.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.