Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pkg/cli/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ func getMarkdownWorkflowFiles(workflowDir string) ([]string, error) {
func fastParseTitle(content string) (string, error) {
firstLine := true
inFrontmatter := false
pastFrontmatter := false
for line := range strings.SplitSeq(content, "\n") {
trimmed := strings.TrimSpace(line)
if firstLine {
Expand All @@ -301,21 +300,19 @@ func fastParseTitle(content string) (string, error) {
inFrontmatter = true
continue
}
// No frontmatter on first line; treat the entire file as markdown.
pastFrontmatter = true
} else if inFrontmatter && !pastFrontmatter {
} else if inFrontmatter {
if trimmed == "---" {
pastFrontmatter = true
inFrontmatter = false
}
continue
}
if pastFrontmatter && strings.HasPrefix(trimmed, "# ") {
if strings.HasPrefix(trimmed, "# ") {
return strings.TrimSpace(trimmed[2:]), nil
}
}

// Unclosed frontmatter is an error (consistent with ExtractFrontmatterFromContent).
if inFrontmatter && !pastFrontmatter {
if inFrontmatter {
return "", errors.New("frontmatter not properly closed")
}

Expand Down
21 changes: 4 additions & 17 deletions pkg/workflow/compiler_error_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,16 @@ type wrappedCompilerError struct {
func (e *wrappedCompilerError) Error() string { return e.formatted }
func (e *wrappedCompilerError) Unwrap() error { return e.cause }

// formatCompilerError creates a formatted compiler error message with optional error wrapping.
// It always uses line:1, column:1 so IDE tooling can navigate to the file even when a
// specific source position is unavailable.
// formatCompilerError creates a formatted compiler error at line 1, column 1.
// Use this when the exact source position is unknown; IDE tooling can still navigate to the file.
// Use formatCompilerErrorWithPosition when a specific line/column is available.
//
// filePath: the file path to include in the error (typically markdownPath or lockFile)
// errType: the error type ("error" or "warning")
// message: the error message text
// cause: optional underlying error to wrap (use nil for validation errors)
func formatCompilerError(filePath string, errType string, message string, cause error) error {
compilerErrorLog.Printf("Formatting compiler error: file=%s, type=%s, message=%s", filePath, errType, message)
formattedErr := console.FormatError(console.CompilerError{
Position: console.ErrorPosition{
File: filePath,
Line: 1,
Column: 1,
},
Type: errType,
Message: message,
})

// Always return a *wrappedCompilerError so isFormattedCompilerError can detect it.
// cause may be nil for validation errors that have no underlying cause.
return &wrappedCompilerError{formatted: formattedErr, cause: cause}
return formatCompilerErrorWithPosition(filePath, 1, 1, errType, message, cause)
}

// isFormattedCompilerError reports whether err is already a console-formatted compiler error
Expand Down
Loading