{"record":{"id":"256310140ff8f8d4","repo":"gohugoio/hugo","slug":"failed-to-open-non-content-file-w","errorCode":null,"errorMessage":"failed to open non-content file: %w","messagePattern":"failed to open non-content file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/content.go","lineNumber":190,"sourceCode":"\t}\n\n\tif err := b.h.Build(hugolib.BuildCfg{NoBuildLock: true, SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil {\n\t\treturn err\n\t}\n\n\tfor i, filename := range contentTargetFilenames {\n\t\tif err := b.applyArcheType(filename, b.dirMap.contentFiles[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Copy the rest as is.\n\tfor _, fi := range b.dirMap.otherFiles {\n\t\tmeta := fi.Meta()\n\n\t\tin, err := meta.Open()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open non-content file: %w\", err)\n\t\t}\n\t\ttargetFilename := filepath.Join(baseDir, b.targetPath, strings.TrimPrefix(fi.Meta().Filename, b.archetypeFi.Meta().Filename))\n\t\ttargetDir := filepath.Dir(targetFilename)\n\n\t\tif err := b.sourceFs.MkdirAll(targetDir, 0o777); err != nil && !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"failed to create target directory for %q: %w\", targetDir, err)\n\t\t}\n\n\t\tout, err := b.sourceFs.Create(targetFilename)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = io.Copy(out, in)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/create/content.go#L172-L208","documentation":"While copying non-content files out of a directory-based archetype bundle (create/content.go:188), Hugo calls fi.Meta().Open() on each 'other' file. This wraps the Open failure, which is typically a permission/IO/symlink problem on an asset inside the archetype.","triggerScenarios":"An archetype directory bundle contains an asset file that cannot be opened: revoked read permission, a broken/dead symlink, a file removed mid-copy, or a virtual-FS path that is stale.","commonSituations":"Broken symlink inside archetypes/; archetype copied from another OS with missing target; archetype on a mount that became unreadable.","solutions":["Inspect the archetype bundle for broken symlinks and remove or fix them.","Verify read permission on every file under the archetypes/ directory.","Recreate the offending asset file in the archetype bundle.","Reduce the archetype bundle to isolate which file triggers the open failure."],"exampleFix":"# before: archetypes/default/index.md -> missing image symlink\narchetypes/default/img.png -> /nonexistent/real.png\n\n# after: ship a real file\n$ cp real.png archetypes/default/img.png","handlingStrategy":"validation","validationCode":"// Verify every file in an archetype bundle is openable before NewContent.\nfunc ValidateArchetypeBundleReadable(fs afero.Fs, dir string) error {\n    return afero.Walk(fs, dir, func(p string, info os.FileInfo, err error) error {\n        if err != nil { return err }\n        if info.IsDir() { return nil }\n        f, err := fs.Open(p)\n        if err != nil { return fmt.Errorf(\"%s: %w\", p, err) }\n        return f.Close()\n    })\n}","typeGuard":null,"tryCatchPattern":"if err := create.NewContent(h, kind, targetPath, force); err != nil {\n    return err\n}","preventionTips":["Avoid broken symlinks inside archetype bundles.","Keep archetype assets readable and on a stable filesystem.","Validate archetype bundles in CI."],"tags":["content","archetype","filesystem"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}