buildImportErrorHint returns a tailored fix hint for an import error based on its message and path.
(message, importPath string)
| 146 | |
| 147 | // buildImportErrorHint returns a tailored fix hint for an import error based on its message and path. |
| 148 | func buildImportErrorHint(message, importPath string) string { |
| 149 | switch { |
| 150 | case message == "failed to resolve import reference": |
| 151 | return fmt.Sprintf("Verify the ref (branch, tag, or SHA) in `%s` is valid and accessible.", importPath) |
| 152 | case strings.Contains(message, "file not found") || strings.Contains(message, "failed to resolve import"): |
| 153 | return fmt.Sprintf("Ensure `%s` exists relative to the workflow directory, or check the `imports:` path.", importPath) |
| 154 | case strings.Contains(message, "failed to download"): |
| 155 | return fmt.Sprintf("Check that the remote import `%s` is accessible and the path is correct.", importPath) |
| 156 | case strings.Contains(message, "invalid import specification"): |
| 157 | return "Use the format `owner/repo/path@ref` for remote imports (e.g. `github/my-org/shared.md@main`)." |
| 158 | default: |
| 159 | return fmt.Sprintf("Check the `imports:` configuration for `%s` and review the error details.", importPath) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // findImportsFieldLocation finds the line and column number of the imports field in YAML content |
| 164 | func findImportsFieldLocation(yamlContent string) (line int, column int) { |