nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kythe/kythe
Pull request #5674 (2023-05-31 16:20:54)

fix(go): use %s to format protos in kzip validation error messages


Patch:
diff --git a/kythe/go/platform/kzip/info/info.go b/kythe/go/platform/kzip/info/info.go
index ea05dfe66..7555620e8 100644
--- a/kythe/go/platform/kzip/info/info.go
+++ b/kythe/go/platform/kzip/info/info.go
@@ -69,10 +69,6 @@ func NewAccumulator(fileSize int64) *Accumulator {
 	}
 }
 
-func cuString(u *kzip.Unit) string {
-	return fmt.Sprintf("corpus: %q root: %q language: %q", u.Proto.GetVName().GetCorpus(), u.Proto.GetVName().GetRoot(), u.Proto.GetVName().GetLanguage())
-}
-
 // Accumulate should be called for each unit in the kzip so its counts can be
 // recorded.
 func (a *Accumulator) Accumulate(u *kzip.Unit) {
@@ -84,7 +80,7 @@ func (a *Accumulator) Accumulate(u *kzip.Unit) {
 
 	cuLang := u.Proto.GetVName().GetLanguage()
 	if cuLang == "" {
-		msg := fmt.Sprintf("CU(%s) does not specify a language", cuString(u))
+		msg := fmt.Sprintf("CU(%s) does not specify a language", u.Proto.GetVName())
 		a.KzipInfo.CriticalKzipErrors = append(a.KzipInfo.CriticalKzipErrors, msg)
 		return
 	}
@@ -107,7 +103,7 @@ func (a *Accumulator) Accumulate(u *kzip.Unit) {
 		riCorpus := requiredInputCorpus(u, ri)
 		if riCorpus == "" {
 			// Trim spaces to work around the fact that log("%v", proto) is inconsistent about trailing spaces in google3 vs open-source go.
-			msg := strings.TrimSpace(fmt.Sprintf("unable to determine corpus for required_input %q in CU(%s)", ri.Info.Path, cuString(u)))
+			msg := strings.TrimSpace(fmt.Sprintf("unable to determine corpus for required_input %q in CU(%s)", ri.Info.Path, u.Proto.GetVName()))
 			a.KzipInfo.CriticalKzipErrors = append(a.KzipInfo.CriticalKzipErrors, msg)
 			return
 		}
@@ -125,7 +121,7 @@ func (a *Accumulator) Accumulate(u *kzip.Unit) {
 	}
 	srcsWithoutRI := srcs.Diff(srcsWithRI)
 	for path := range srcsWithoutRI {
-		msg := fmt.Sprintf("source %q in CU(%s) doesn't have a required_input entry", path, cuString(u))
+		msg := fmt.Sprintf("source %q in CU(%s) doesn't have a required_input entry", path, u.Proto.GetVName())
 		a.KzipInfo.CriticalKzipErrors = append(a.KzipInfo.CriticalKzipErrors, msg)
 	}
 	if srcCorpora.Len() != 1 {


Test patch:
diff --git a/kythe/go/platform/kzip/info/info_test.go b/kythe/go/platform/kzip/info/info_test.go
index a592799da..78113b308 100644
--- a/kythe/go/platform/kzip/info/info_test.go
+++ b/kythe/go/platform/kzip/info/info_test.go
@@ -295,7 +295,7 @@ var infoTests = []struct {
 					},
 				},
 			},
-			CriticalKzipErrors: []string{`unable to determine corpus for required_input "file1.py" in CU(corpus: "" root: "" language: "python")`},
+			CriticalKzipErrors: []string{`unable to determine corpus for required_input "file1.py" in CU(language:"python")`},
 		},
 	},
Repository: kythe/kythe
Pull request #5694 (2023-06-09 20:03:14)

chore: use return value of emitNameUsage


Patch:
diff --git a/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java b/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
index 002101736..2c161e3d0 100644
--- a/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
+++ b/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
@@ -921,8 +921,7 @@ public class KytheTreeScanner extends JCTreeScanner<JavaNode, TreeContext> {
       } else if (invoke.getMethodSelect() instanceof JCFieldAccess) {
         JCFieldAccess field = (JCFieldAccess) invoke.getMethodSelect();
         if (field.sym != null && field.name != null) {
-          emitNameUsage(methodCtx, field.sym, field.name, kind);
-          return method;
+          return emitNameUsage(methodCtx, field.sym, field.name, kind);
         }
       }
       // fall-through to handle non-identifier invocations


Test patch:
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CallgraphIdent.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CallgraphIdent.java
index 9f6259f94..c9379ba91 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CallgraphIdent.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CallgraphIdent.java
@@ -39,7 +39,10 @@ public class CallgraphIdent {
       g();
     }
 
-    //- @n ref/call N
+    //- @h=HCall ref/call H
+    //- HCall childof ClassInit
+    //- @n=NestedCall ref/call N
+    //- NestedCall childof ClassInit
     h().n();
   }
 
@@ -94,6 +97,7 @@ public class CallgraphIdent {
     return 0;
   }
 
+  //- @h defines/binding H
   static Nested h() {
     return new Nested();
   }
Repository: kythe/kythe
Pull request #4621 (2020-08-03 18:39:11)

fix(serving): turn diffmatchpatch panics into internal errors


Patch:
diff --git a/kythe/go/serving/xrefs/xrefs.go b/kythe/go/serving/xrefs/xrefs.go
index 3c61f4dc1..3a436b009 100644
--- a/kythe/go/serving/xrefs/xrefs.go
+++ b/kythe/go/serving/xrefs/xrefs.go
@@ -260,7 +260,10 @@ func (t *Table) Decorations(ctx context.Context, req *xpb.DecorationsRequest) (*
 
 	var patcher *span.Patcher
 	if len(req.DirtyBuffer) > 0 {
-		patcher = span.NewPatcher(decor.File.Text, req.DirtyBuffer)
+		patcher, err = span.NewPatcher(decor.File.Text, req.DirtyBuffer)
+		if err != nil {
+			return nil, status.Errorf(codes.Internal, "error patching decorations for %s: %v", req.Location.Ticket, err)
+		}
 	}
 
 	// The span with which to constrain the set of returned anchor references.
diff --git a/kythe/go/util/span/span.go b/kythe/go/util/span/span.go
index 2a45d8308..4c084e07a 100644
--- a/kythe/go/util/span/span.go
+++ b/kythe/go/util/span/span.go
@@ -52,9 +52,15 @@ type Patcher struct {
 }
 
 // NewPatcher returns a Patcher based on the diff between oldText and newText.
-func NewPatcher(oldText, newText []byte) *Patcher {
+func NewPatcher(oldText, newText []byte) (p *Patcher, err error) {
+	defer func() {
+		// dmp may panic on some large requests; catch it and return an error instead
+		if r := recover(); r != nil {
+			err = fmt.Errorf("diffmatchpatch panic: %v", r)
+		}
+	}()
 	dmp := diffmatchpatch.New()
-	return &Patcher{dmp, dmp.DiffCleanupEfficiency(dmp.DiffMain(string(oldText), string(newText), true))}
+	return &Patcher{dmp, dmp.DiffCleanupEfficiency(dmp.DiffMain(string(oldText), string(newText), true))}, nil
 }
 
 // Patch returns the resulting span of mapping the given span from the Patcher's


Test patch:
diff --git a/kythe/go/util/span/span_test.go b/kythe/go/util/span/span_test.go
index 1d9e9749d..c280d792c 100644
--- a/kythe/go/util/span/span_test.go
+++ b/kythe/go/util/span/span_test.go
@@ -132,7 +132,10 @@ func TestPatcher(t *testing.T) {
 	}}
 
 	for _, test := range tests {
-		p := NewPatcher([]byte(test.oldText), []byte(test.newText))
+		p, err := NewPatcher([]byte(test.oldText), []byte(test.newText))
+		if err != nil {
+			t.Fatal(err)
+		}
 		if len(test.oldSpans) != len(test.newSpans) {
 			t.Fatalf("Invalid test: {%v}", test)
 		}
Repository: kythe/kythe
Pull request #5416 (2022-10-31 18:42:21)

fix(textproto): use ref/file for proto-file schema comments
"ref" was used previously, but "ref/file" is slightly more correct since the target vname is a file


Patch:
diff --git a/kythe/cxx/indexer/textproto/analyzer.cc b/kythe/cxx/indexer/textproto/analyzer.cc
index 6224f334e..22e7e0645 100644
--- a/kythe/cxx/indexer/textproto/analyzer.cc
+++ b/kythe/cxx/indexer/textproto/analyzer.cc
@@ -723,7 +723,7 @@ absl::Status TextprotoAnalyzer::AnalyzeSchemaComments(
 
     // Add ref edge to file.
     proto::VName v = VNameForRelPath(file);
-    recorder_->AddEdge(VNameRef(anchor), EdgeKindID::kRef, VNameRef(v));
+    recorder_->AddEdge(VNameRef(anchor), EdgeKindID::kRefFile, VNameRef(v));
   }
 
   return absl::OkStatus();


Test patch:
diff --git a/kythe/cxx/indexer/textproto/testdata/schema_comments.pbtxt b/kythe/cxx/indexer/textproto/testdata/schema_comments.pbtxt
index 63a2f6336..e9c0b014d 100644
--- a/kythe/cxx/indexer/textproto/testdata/schema_comments.pbtxt
+++ b/kythe/cxx/indexer/textproto/testdata/schema_comments.pbtxt
@@ -1,11 +1,11 @@
 
-#- @"kythe/cxx/indexer/textproto/testdata/example.proto" ref vname(_,_,"","kythe/cxx/indexer/textproto/testdata/example.proto",_)
+#- @"kythe/cxx/indexer/textproto/testdata/example.proto" ref/file vname(_,_,"","kythe/cxx/indexer/textproto/testdata/example.proto",_)
 # proto-file: kythe/cxx/indexer/textproto/testdata/example.proto
 
 #- @"example.Message2" ref Message2
 # proto-message: example.Message2
 
-#- @"kythe/cxx/indexer/textproto/testdata/example.proto" ref vname(_,_,"","kythe/cxx/indexer/textproto/testdata/example.proto",_)
+#- @"kythe/cxx/indexer/textproto/testdata/example.proto" ref/file vname(_,_,"","kythe/cxx/indexer/textproto/testdata/example.proto",_)
 # proto-import: kythe/cxx/indexer/textproto/testdata/example.proto
 
 #- @field1 ref Field1