{"record":{"id":"b96635d04d122a1e","repo":"evanw/esbuild","slug":"invalid-fallback-path-s","errorCode":null,"errorMessage":"Invalid fallback path: %s","messagePattern":"Invalid fallback path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/api/serve_other.go","lineNumber":780,"sourceCode":"\tif (serveOptions.Keyfile != \"\") != (serveOptions.Certfile != \"\") {\n\t\treturn ServeResult{}, errors.New(\"Must specify both key and certificate for HTTPS\")\n\t}\n\n\t// Validate the \"servedir\" path\n\tif serveOptions.Servedir != \"\" {\n\t\tif absPath, ok := ctx.realFS.Abs(serveOptions.Servedir); ok {\n\t\t\tserveOptions.Servedir = absPath\n\t\t} else {\n\t\t\treturn ServeResult{}, fmt.Errorf(\"Invalid serve path: %s\", serveOptions.Servedir)\n\t\t}\n\t}\n\n\t// Validate the \"fallback\" path\n\tif serveOptions.Fallback != \"\" {\n\t\tif absPath, ok := ctx.realFS.Abs(serveOptions.Fallback); ok {\n\t\t\tserveOptions.Fallback = absPath\n\t\t} else {\n\t\t\treturn ServeResult{}, fmt.Errorf(\"Invalid fallback path: %s\", serveOptions.Fallback)\n\t\t}\n\t}\n\n\t// Validate the CORS origins\n\tfor _, origin := range serveOptions.CORS.Origin {\n\t\tif star := strings.IndexByte(origin, '*'); star >= 0 && strings.ContainsRune(origin[star+1:], '*') {\n\t\t\treturn ServeResult{}, fmt.Errorf(\"Invalid origin: %s\", origin)\n\t\t}\n\t}\n\n\t// Stuff related to the output directory only matters if there are entry points\n\toutdirPathPrefix := \"\"\n\tif len(ctx.args.entryPoints) > 0 {\n\t\t// Don't allow serving when builds are written to stdout\n\t\tif ctx.args.options.WriteToStdout {\n\t\t\twhat := \"entry points\"\n\t\t\tif len(ctx.args.entryPoints) == 1 {\n\t\t\t\twhat = \"an entry point\"","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/pkg/api/serve_other.go#L762-L798","documentation":"The fallback option for serve mode (the file served when no route matches) must be resolvable to an absolute path. This error fires when ctx.realFS.Abs(serveOptions.Fallback) fails.","triggerScenarios":"Passing a fallback file path that does not exist or cannot be resolved to an absolute path.","commonSituations":"Pointing fallback to a deleted or renamed file (e.g. 'index.html' moved to '404.html'), a typo'd path, or a path with permission issues.","solutions":["Verify the fallback file path exists and is readable before starting serve mode","Use an absolute path for the fallback file","Remove the fallback option if you do not need SPA-style fallback routing"],"exampleFix":"// before\nesbuild.serve({ servedir: '.', fallback: './missing.html' })\n// after\nesbuild.serve({ servedir: '.', fallback: path.resolve('./public/404.html') })","handlingStrategy":"validation","validationCode":"import fs from 'fs'\nimport path from 'path'\nfunction validateFallback(fallback) {\n  if (!fallback) return ''\n  const abs = path.resolve(fallback)\n  if (!fs.existsSync(abs) || !fs.statSync(abs).isFile()) {\n    throw new Error(`fallback file does not exist: ${abs}`)\n  }\n  return abs\n}\nserveOptions.fallback = validateFallback(serveOptions.fallback)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check that the fallback file exists and is readable before starting serve mode","Resolve the fallback path to absolute before passing it","Remove the fallback option if you do not need SPA-style routing"],"tags":["esbuild","serve","filesystem","path"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}