{"record":{"id":"13e1224415aa3223","repo":"gohugoio/hugo","slug":"failed-to-read-q-w","errorCode":null,"errorMessage":"failed to read %q: %w","messagePattern":"failed to read %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/resolve.go","lineNumber":315,"sourceCode":"\t\t\treturn api.OnResolveResult{Path: m.Filename, Namespace: NsHugoImport}, nil\n\t\t}\n\n\t\t// Fall back to ESBuild's resolve.\n\t\treturn api.OnResolveResult{}, nil\n\t}\n\n\timportResolver := api.Plugin{\n\t\tName: \"hugo-import-resolver\",\n\t\tSetup: func(build api.PluginBuild) {\n\t\t\tbuild.OnResolve(api.OnResolveOptions{Filter: `.*`},\n\t\t\t\tfunc(args api.OnResolveArgs) (api.OnResolveResult, error) {\n\t\t\t\t\treturn resolveImport(args)\n\t\t\t\t})\n\t\t\tbuild.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: NsHugoImport},\n\t\t\t\tfunc(args api.OnLoadArgs) (api.OnLoadResult, error) {\n\t\t\t\t\tb, err := os.ReadFile(args.Path)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn api.OnLoadResult{}, fmt.Errorf(\"failed to read %q: %w\", args.Path, err)\n\t\t\t\t\t}\n\t\t\t\t\tc := string(b)\n\n\t\t\t\t\treturn api.OnLoadResult{\n\t\t\t\t\t\t// See https://github.com/evanw/esbuild/issues/502\n\t\t\t\t\t\t// This allows all modules to resolve dependencies\n\t\t\t\t\t\t// in the main project's node_modules.\n\t\t\t\t\t\tResolveDir: opts.ResolveDir,\n\t\t\t\t\t\tContents:   &c,\n\t\t\t\t\t\tLoader:     opts.loaderFromFilename(args.Path),\n\t\t\t\t\t}, nil\n\t\t\t\t})\n\t\t\tbuild.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: NsHugoImportResolveFunc},\n\t\t\t\tfunc(args api.OnLoadArgs) (api.OnLoadResult, error) {\n\t\t\t\t\tc, err := opts.ImportOnLoadFunc(args)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn api.OnLoadResult{}, err\n\t\t\t\t\t}","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/js/esbuild/resolve.go#L297-L333","documentation":"Returned from the Hugo import resolver's OnLoad callback when os.ReadFile(args.Path) fails for a file resolved into the ns-hugo-imp namespace. The wrapped error contains the OS-level read failure.","triggerScenarios":"An asset was resolved successfully but, by the time esbuild loads it via the OnLoad callback, the file is unreadable — deleted, moved, or has restrictive permissions between resolve and load.","commonSituations":"Hugo server with a file rename/delete happening concurrently; CI pulling assets via a submodule that wasn't initialized; OS permission denied; git LFS pointer file instead of real content.","solutions":["Verify the file at the printed path exists and is readable.","Restart hugo server to re-resolve against the current filesystem.","Check submodule and git LFS state to ensure real content is present."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Treat read failures during server mode as transient: on this error, re-resolve the asset once and retry; on persistent failure surface the path to the user as a missing-asset diagnostic.","preventionTips":["Do not move or delete /assets files mid-build.","Ensure submodules are initialized and git LFS pointers are resolved before building.","Run hugo server with --renderToMemory if assets churn frequently to reduce disk races."],"tags":["esbuild","resolve","io","assets"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}