From 29e5c269a16632c79ca3160b097ccde86a35cf09 Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Sat, 15 Mar 2025 10:11:55 +0000 Subject: [PATCH] Fix - accidentally omitted path Prefix for filePathMap files This means prebuilt projects referencing other files do not work properly. This wasn't caught by tests because the files have previously been uploaded to Vercel, so the hashes match existing files and the paths are correct at deployment time. --- vercel/data_source_prebuilt_project.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vercel/data_source_prebuilt_project.go b/vercel/data_source_prebuilt_project.go index fda22682..415a943a 100644 --- a/vercel/data_source_prebuilt_project.go +++ b/vercel/data_source_prebuilt_project.go @@ -283,21 +283,21 @@ func processVCConfigFile(configPath, projectPath string, config *PrebuiltProject // Process each file in the filePathMap for filePath := range vcConfig.FilePathMap { - // Don't process if we've already added this file - if _, exists := config.Output[filePath]; exists { - continue - } - // Make sure the path is absolute relative to the project absPath := filePath if !filepath.IsAbs(absPath) { absPath = filepath.Join(projectPath, absPath) } + // Don't process if we've already added this file + if _, exists := config.Output[absPath]; exists { + continue + } + // Check if file exists fileInfo, err := os.Lstat(absPath) // Use Lstat to not follow symlinks if err != nil { - return fmt.Errorf("could not stat file %s referenced in filePathMap: %w", absPath, err) + return fmt.Errorf("could not stat file %s (%s) referenced in filePathMap: %w", filePath, absPath, err) } // Skip directories @@ -309,24 +309,24 @@ func processVCConfigFile(configPath, projectPath string, config *PrebuiltProject // It's a symlink - read the target path linkTarget, err := os.Readlink(absPath) if err != nil { - return fmt.Errorf("could not read symlink %s: %w", absPath, err) + return fmt.Errorf("could not read symlink %s (%s): %w", filePath, absPath, err) } // Hash the link target string (just like Vercel does) targetData := []byte(linkTarget) rawSha := sha1.Sum(targetData) sha := hex.EncodeToString(rawSha[:]) - config.Output[filePath] = fmt.Sprintf("%d~%s", len(targetData), sha) + config.Output[absPath] = fmt.Sprintf("%d~%s", len(targetData), sha) } else { // Regular file - read and hash its content fileContent, err := os.ReadFile(absPath) if err != nil { - return fmt.Errorf("could not read file %s referenced in filePathMap: %w", absPath, err) + return fmt.Errorf("could not read file %s (%s) referenced in filePathMap: %w", filePath, absPath, err) } rawSha := sha1.Sum(fileContent) sha := hex.EncodeToString(rawSha[:]) - config.Output[filePath] = fmt.Sprintf("%d~%s", len(fileContent), sha) + config.Output[absPath] = fmt.Sprintf("%d~%s", len(fileContent), sha) } }