{"record":{"id":"7c8370be929ea574","repo":"github/copilot-sdk","slug":"failed-to-evaluate-build-constraints-in-q-w","errorCode":null,"errorMessage":"failed to evaluate build constraints in %q: %w","messagePattern":"failed to evaluate build constraints in %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/cmd/bundler/main.go","lineNumber":234,"sourceCode":"\tif err != nil {\n\t\treturn defaultPackageName, fmt.Errorf(\"failed to read package directory %q: %w\", dir, err)\n\t}\n\n\tbuildContext := build.Default\n\tbuildContext.GOOS = goos\n\tbuildContext.GOARCH = goarch\n\n\tpackageName := \"\"\n\tfor _, entry := range entries {\n\t\tname := entry.Name()\n\t\tif entry.IsDir() || !strings.HasSuffix(name, \".go\") ||\n\t\t\tstrings.HasPrefix(name, \".\") || strings.HasPrefix(name, \"_\") ||\n\t\t\tstrings.HasSuffix(name, \"_test.go\") || strings.HasPrefix(name, \"zcopilot_\") {\n\t\t\tcontinue\n\t\t}\n\t\tmatches, err := buildContext.MatchFile(dir, name)\n\t\tif err != nil {\n\t\t\treturn defaultPackageName, fmt.Errorf(\"failed to evaluate build constraints in %q: %w\", filepath.Join(dir, name), err)\n\t\t}\n\t\tif !matches {\n\t\t\tcontinue\n\t\t}\n\n\t\tpath := filepath.Join(dir, name)\n\t\tfile, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.PackageClauseOnly)\n\t\tif err != nil {\n\t\t\treturn defaultPackageName, fmt.Errorf(\"failed to parse package clause in %q: %w\", path, err)\n\t\t}\n\n\t\tif packageName == \"\" {\n\t\t\tpackageName = file.Name.Name\n\t\t\tcontinue\n\t\t}\n\t\tif packageName != file.Name.Name {\n\t\t\treturn defaultPackageName, fmt.Errorf(\"multiple packages %q and %q found in %q\", packageName, file.Name.Name, dir)\n\t\t}","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L216-L252","documentation":"While scanning candidate .go files to detect the package name, detectPackageName calls buildContext.MatchFile to evaluate build constraints (build tags, GOOS/GOARCH fit). This error wraps any failure from that evaluation for a specific file, falling back to defaultPackageName.","triggerScenarios":"A .go file in the package directory has malformed build constraints (e.g. malformed //go:build lines) that go/build cannot parse for the target platform, causing buildContext.MatchFile(dir, name) to return an error.","commonSituations":"Hand-edited or conflicting //go:build and // +build lines; non-UTF8 or corrupt files; generated files with broken constraint syntax; cross-compiling to a platform where constraint evaluation hits an unsupported combination.","solutions":["Open the file named in the error and fix its //go:build / // +build constraint syntax.","Remove or regenerate the offending file if it is generated or vestigial.","Run `go vet ./...` on the directory to surface malformed build constraints.","Ensure only one of //go:build and // +build is authoritative and they agree."],"exampleFix":"// before (broken constraint in file.go)\n// +build linux amd64\n//go:build linux && amd64 &&\n\n// after\n//go:build linux && amd64\n// +build linux,amd64","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"matches, err := buildContext.MatchFile(dir, name)\nif err != nil {\n    log.Printf(\"skipping %s: bad build constraints: %v\", filepath.Join(dir, name), err)\n    continue // or fix the file, depending on strictness\n}","preventionTips":["Run `go vet ./...` to catch malformed //go:build lines early.","Keep //go:build and // +build lines in agreement or drop the legacy form.","Regenerate or remove corrupt/generated files with broken constraints."],"tags":["build-constraints","go","filesystem","cli"],"backgroundTag":"invalid-build-constraint","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}