diff --git a/pkg/cli/workflows.go b/pkg/cli/workflows.go index e721eec2fc..3bd320b518 100644 --- a/pkg/cli/workflows.go +++ b/pkg/cli/workflows.go @@ -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 { @@ -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") } diff --git a/pkg/workflow/compiler_error_formatter.go b/pkg/workflow/compiler_error_formatter.go index b5b64b678a..fdcf0167e2 100644 --- a/pkg/workflow/compiler_error_formatter.go +++ b/pkg/workflow/compiler_error_formatter.go @@ -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