{"record":{"id":"d4bd50f209744f5f","repo":"vitessio/vitess","slug":"missing-file-on-disk-s-w","errorCode":null,"errorMessage":"missing file on disk: %s (%w)","messagePattern":"missing file on disk: (.+?) \\(%w\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/tools/asthelpergen/asthelpergen.go","lineNumber":228,"sourceCode":"\t\treturn nil, err\n\t}\n\n\tresult := map[string]*jen.File{}\n\tfor fName, genFile := range jenFiles {\n\t\tfullPath := path.Join(gen.mod.Dir, strings.TrimPrefix(pkg.Path(), gen.mod.Path), fName)\n\t\tresult[fullPath] = genFile\n\t}\n\n\treturn result, nil\n}\n\n// VerifyFilesOnDisk compares the generated results from the codegen against the files that\n// currently exist on disk and returns any mismatches\nfunc VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) {\n\tfor fullPath, file := range result {\n\t\texisting, err := os.ReadFile(fullPath)\n\t\tif err != nil {\n\t\t\terrors = append(errors, fmt.Errorf(\"missing file on disk: %s (%w)\", fullPath, err))\n\t\t\tcontinue\n\t\t}\n\n\t\tgenFile, err := codegen.FormatJenFile(file)\n\t\tif err != nil {\n\t\t\terrors = append(errors, fmt.Errorf(\"goimport error: %w\", err))\n\t\t\tcontinue\n\t\t}\n\n\t\tif !bytes.Equal(existing, genFile) {\n\t\t\terrors = append(errors, fmt.Errorf(\"'%s' has changed\", fullPath))\n\t\t\tcontinue\n\t\t}\n\t}\n\treturn errors\n}\n\n// Options configures the AST helper generation process.","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/tools/asthelpergen/asthelpergen.go#L210-L246","documentation":"VerifyFilesOnDisk compares each generated file against the file on disk. If os.ReadFile fails for the expected output path, the error is collected with the OS error wrapped, meaning the codegen expects a file that does not exist (or is unreadable).","triggerScenarios":"Running `asthelpergen verify` (or TestFullGeneration) after generated files were deleted or never committed; the result map contains paths like go/vt/sqlparser/ast_clone.go that are absent on disk.","commonSituations":"Fresh clone before running `make codegen`; a developer deleted generated files; file permissions or a wrong output directory cause ReadFile to fail.","solutions":["Run `asthelpergen` (or `make codegen`) without verify to generate and write the missing files","Restore the deleted generated files (git checkout -- go/vt/sqlparser/)","Check file permissions on the expected output path"],"exampleFix":"// before (verify fails)\n$ asthelpergen verify\n// after\n$ asthelpergen && asthelpergen verify","handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(expectedPath); os.IsNotExist(err) {\n    fmt.Printf(\"missing generated file %s; run make codegen\\n\", expectedPath)\n}","typeGuard":null,"tryCatchPattern":"errs := VerifyFilesOnDisk(result)\nfor _, err := range errs {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && os.IsNotExist(pe) {\n        // regenerate instead of failing verification\n    }\n}","preventionTips":["Run `make codegen` before running verify","Never delete generated files without regenerating","Keep generated files committed so fresh clones pass verification"],"tags":["codegen","filesystem","verification"],"backgroundTag":"generated-files-missing","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}