MCPcopy Create free account
hub / github.com/github/gh-aw / buildImportErrorHint

Function buildImportErrorHint

pkg/parser/import_error.go:148–161  ·  view source on GitHub ↗

buildImportErrorHint returns a tailored fix hint for an import error based on its message and path.

(message, importPath string)

Source from the content-addressed store, hash-verified

146
147// buildImportErrorHint returns a tailored fix hint for an import error based on its message and path.
148func 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
164func findImportsFieldLocation(yamlContent string) (line int, column int) {

Callers 1

FormatImportErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected