diff --git a/bundle/config/mutator/translate_notebook_paths.go b/bundle/config/mutator/translate_notebook_paths.go index 0e629d3d..b5702024 100644 --- a/bundle/config/mutator/translate_notebook_paths.go +++ b/bundle/config/mutator/translate_notebook_paths.go @@ -3,7 +3,6 @@ package mutator import ( "context" "fmt" - "os" "path" "path/filepath" "strings" @@ -35,10 +34,6 @@ func (m *translateNotebookPaths) rewritePath(b *bundle.Bundle, p *string) error absPath := filepath.Join(b.Config.Path, relPath) nb, _, err := notebook.Detect(absPath) if err != nil { - // Ignore if this file doesn't exist. Maybe it's an absolute workspace path? - if os.IsNotExist(err) { - return nil - } return fmt.Errorf("unable to determine if %s is a notebook: %w", relPath, err) } diff --git a/libs/notebook/detect.go b/libs/notebook/detect.go index ad751fa0..38b9ec18 100644 --- a/libs/notebook/detect.go +++ b/libs/notebook/detect.go @@ -3,6 +3,8 @@ package notebook import ( "bufio" "bytes" + "errors" + "fmt" "io" "os" "path/filepath" @@ -39,6 +41,10 @@ func readHeader(path string) ([]byte, error) { func Detect(path string) (notebook bool, language workspace.Language, err error) { header := "" + if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { + return false, "", fmt.Errorf("file %s does not exist", path) + } + // Determine which header to expect based on filename extension. ext := strings.ToLower(filepath.Ext(path)) switch ext {