{"record":{"id":"538455e1dc7f3358","repo":"gohugoio/hugo","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/build.go","lineNumber":173,"sourceCode":"\t\t\t\tcontentr = resolvedError.Content\n\t\t\t\terrorPath = resolvedError.Path\n\t\t\t\terrorMessage = resolvedError.Message\n\t\t\t}\n\n\t\t\tif contentr != nil {\n\t\t\t\tdefer contentr.Close()\n\t\t\t}\n\n\t\t\tif err == nil {\n\t\t\t\tfe := herrors.\n\t\t\t\t\tNewFileErrorFromName(errors.New(errorMessage), errorPath).\n\t\t\t\t\tUpdatePosition(text.Position{Offset: -1, LineNumber: loc.Line, ColumnNumber: loc.Column}).\n\t\t\t\t\tUpdateContent(contentr, nil)\n\n\t\t\t\treturn fe\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"%s\", errorMessage)\n\t\t}\n\n\t\tvar errors []error\n\n\t\tfor _, msg := range result.Errors {\n\t\t\terrors = append(errors, createErr(msg))\n\t\t}\n\n\t\t// Return 1, log the rest.\n\t\tfor i, err := range errors {\n\t\t\tif i > 0 {\n\t\t\t\tc.rs.Logger.Errorf(\"js.Build failed: %s\", err)\n\t\t\t}\n\t\t}\n\n\t\treturn result, errors[0]\n\t}\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/js/esbuild/build.go#L155-L191","documentation":"The fallback error formatter used in BuildClient.Build when an esbuild error has a Location but Hugo fails to open or stat the referenced source file. When the file lookup itself errors, the original esbuild message text is returned via fmt.Errorf(\"%s\", errorMessage) without source-context attachment.","triggerScenarios":"Esbuild returns a build error referencing a file path; Hugo's attempt to open/stat that path (either on the OS filesystem or the source filesystem) fails with err != nil. The fallback path executes, returning the bare esbuild text without line-anchored content.","commonSituations":"Errors pointing to generated/virtual files that have no backing on disk; transient file-not-found during server rebuilds; source files in Hugo namespaces that don't map to a real file.","solutions":["Read the message text directly — it is esbuild's original diagnostic.","Cross-reference the failing import/entry point in your assets to reconstruct context.","If reproducible, run `hugo --gc` to clear stale state and rebuild."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"When Build returns an error, do not assume it carries source-line context; check whether the error implements herrors.FileError before rendering line annotations, and fall back to printing the raw message text.","preventionTips":["Treat the message text as authoritative when source context is absent.","Don't depend on line/column annotations in your error UI for this path.","Cross-reference the failing import in your assets manually when this fallback fires."],"tags":["esbuild","error-reporting","diagnostics"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}