{"record":{"id":"013a22fa1971021f","repo":"gastownhall/beads","slug":"parse-s-w-013a22","errorCode":null,"errorMessage":"parse %s: %w","messagePattern":"parse (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/schemagen/schemagen.go","lineNumber":55,"sourceCode":"\tDoc      string\n}\n\n// Generate parses typesPath and returns gofmt'd source for schema_gen.go.\n// The output is deterministic given the same input.\nfunc Generate(typesPath string) ([]byte, error) {\n\tprims, err := Parse(typesPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn Render(prims)\n}\n\n// Parse extracts every exported struct in typesPath, sorted by name.\nfunc Parse(typesPath string) ([]Primitive, error) {\n\tfset := token.NewFileSet()\n\tfile, err := parser.ParseFile(fset, typesPath, nil, parser.ParseComments)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse %s: %w\", typesPath, err)\n\t}\n\n\tvar prims []Primitive\n\tfor _, decl := range file.Decls {\n\t\tgen, ok := decl.(*ast.GenDecl)\n\t\tif !ok || gen.Tok != token.TYPE {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, spec := range gen.Specs {\n\t\t\tts, ok := spec.(*ast.TypeSpec)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !ts.Name.IsExported() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tst, ok := ts.Type.(*ast.StructType)\n\t\t\tif !ok {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/schemagen/schemagen.go#L37-L73","documentation":"schemagen.Parse reads a Go source file with go/parser to extract exported struct types. This error wraps any failure of parser.ParseFile on typesPath, e.g. the file does not exist, is not valid Go, or has syntax errors. It is reported during Generate when reading the user-supplied types file.","triggerScenarios":"Calling Generate with a typesPath that points to a missing file, a directory, a non-Go file, or Go source containing syntax errors.","commonSituations":"Wrong path passed to the schema generator (typo or relative vs absolute path), generated code not yet written, or a Go file edited and left with a syntax error.","solutions":["Verify typesPath exists and is a .go file (run `go build ./...` on it independently).","Run `gofmt -e <file>` or `go vet` on the file to see the underlying syntax error.","Correct the syntax error in the types file reported in the wrapped %w error.","Ensure the path is correct relative to the working directory of the process calling Generate."],"exampleFix":"// before\nprims, err := schemagen.Parse(\"./types.go\")\n// after\nprims, err := schemagen.Parse(\"internal/types/types.go\") // correct, existing path","handlingStrategy":"validation","validationCode":"if info, err := os.Stat(typesPath); err != nil || info.IsDir() {\n    return fmt.Errorf(\"typesPath %q is not a readable file\", typesPath)\n}\nif _, err := parser.ParseFile(token.NewFileSet(), typesPath, nil, parser.AllErrors); err != nil {\n    return fmt.Errorf(\"typesPath has syntax errors: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"var pe *scanner.ErrorList\nif errors.As(err, &pe) { for _, e := range *pe { log.Printf(\"%s:%d: %s\", e.Pos.Filename, e.Pos.Line, e.Msg) } }","preventionTips":["Run `gofmt -e`/`go build` on generated types files before invoking schemagen.","Use absolute or repo-root-relative paths for typesPath.","Generate types files before running schemagen in build pipelines."],"tags":["golang","ast-parsing","schemagen"],"backgroundTag":"go-source-parse-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}