Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 24, 2025

File-related errors (parsing failures, YAML unmarshal errors, parameter expansion errors) did not indicate which file caused the issue, making debugging difficult when processing multiple files.

Changes:

  • markdown.go: Added file path to open, scan, and unmarshal frontmatter errors
  • context.go: Added file path to parse and parameter expansion errors for tasks, commands, and rules
  • markdown_test.go: Added test coverage to verify file paths appear in error messages

Example:

Before: failed to unmarshal frontmatter: [1:16] found an invalid key
After:  failed to unmarshal frontmatter in file /path/to/bad_rule.md: [1:16] found an invalid key
Original prompt

When an error is about a specific file, is should state which file is at fault.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add file reporting to error messages Add file paths to error messages Dec 24, 2025
Copilot AI requested a review from alexec December 24, 2025 00:51
@alexec alexec marked this pull request as ready for review December 24, 2025 00:52
Copilot AI review requested due to automatic review settings December 24, 2025 00:52
@alexec alexec enabled auto-merge (squash) December 24, 2025 00:53
@alexec alexec merged commit 40b7c0a into main Dec 24, 2025
5 checks passed
@alexec alexec deleted the copilot/add-error-file-reporting branch December 24, 2025 00:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error messages by adding file paths to parsing, unmarshaling, and parameter expansion errors, making it easier to debug issues when processing multiple files.

  • Added file paths to error messages in markdown.go for open, scan, and unmarshal operations
  • Added file paths to error messages in context.go for parse and parameter expansion errors in tasks, commands, and rules
  • Added test coverage to verify file paths appear in error messages

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/codingcontext/markdown/markdown.go Added file path parameter to three error messages (open, scan, unmarshal frontmatter) for better error diagnostics
pkg/codingcontext/context.go Added file path parameter to four error messages (task parse, task parameter expansion, command parameter expansion, rule parameter expansion)
pkg/codingcontext/markdown/markdown_test.go Added test coverage for file path inclusion in error messages with table-driven test following project standards

Comment on lines +111 to +125
func TestParseMarkdownFile_ErrorsIncludeFilePath(t *testing.T) {
tests := []struct {
name string
content string
want string // substring that should appear in error
}{
{
name: "invalid YAML in frontmatter",
content: `---
invalid: yaml: : syntax
---
Content here`,
want: "failed to unmarshal frontmatter in file",
},
}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage for error messages is good, but it only covers the unmarshal error case. Consider adding a test case for the scan error on line 71 of markdown.go to ensure complete coverage of all file path error messages. However, since scanner errors are rare and difficult to simulate, this is a minor suggestion.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants