nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: GoogleChrome/lighthouse
Pull request #12872 (2021-08-05 20:38:00)

report(dom): handle undefined link url from proto roundtrip
ref #12868

___

Commit with message:
```
Co-authored-by: André Van Dal <me@andrevandal.dev>
```


Patch:
diff --git a/report/renderer/dom.js b/report/renderer/dom.js
index 8b3894300..550f41dc7 100644
--- a/report/renderer/dom.js
+++ b/report/renderer/dom.js
@@ -154,6 +154,9 @@ export class DOM {
    * @param {string} url
    */
   safelySetHref(elem, url) {
+    // Defaults to '' to fix proto roundtrip issue. See https://github.com/GoogleChrome/lighthouse/issues/12868
+    url = url || '';
+
     // In-page anchor links are safe.
     if (url.startsWith('#')) {
       elem.href = url;


Test patch:
diff --git a/report/test/renderer/dom-test.js b/report/test/renderer/dom-test.js
index aadf62802..867c99f14 100644
--- a/report/test/renderer/dom-test.js
+++ b/report/test/renderer/dom-test.js
@@ -193,8 +193,13 @@ describe('DOM', () => {
         expect(a.getAttribute('href')).toEqual(null);
       });
     });
-  });
 
+    it('handles if url is undefined (because of proto roundtrip)', () => {
+      const a = dom.createElement('a');
+      dom.safelySetHref(a, undefined);
+      expect(a.href).toEqual('');
+    });
+  });
 
   describe('safelySetBlobHref', () => {
     it('sets href for safe blob types', () => {
Repository: GoogleChrome/lighthouse
Pull request #12899 (2021-08-10 20:50:45)

tests(devtools): sync


Patch:
diff --git a/lighthouse-cli/cli-flags.js b/lighthouse-cli/cli-flags.js
index aab061061..4b4b72b33 100644
--- a/lighthouse-cli/cli-flags.js
+++ b/lighthouse-cli/cli-flags.js
@@ -362,16 +362,20 @@ function coerceOptionalStringBoolean(value) {
  */
 function coerceOutput(values) {
   const outputTypes = ['json', 'html', 'csv'];
-  const errorMsg = `Invalid values. Argument 'output' must be an array from choices "${outputTypes.join('", "')}"`;
+  const errorHint = `Argument 'output' must be an array from choices "${outputTypes.join('", "')}"`;
   if (!values.every(/** @return {item is string} */ item => typeof item === 'string')) {
-    throw new Error(errorMsg);
+    throw new Error('Invalid values. ' + errorHint);
   }
   // Allow parsing of comma-separated values.
   const strings = values.flatMap(value => value.split(','));
-  if (!strings.every(/** @return {str is LH.OutputMode} */ str => outputTypes.includes(str))) {
-    throw new Error(errorMsg);
-  }
-  return strings;
+  const validValues = strings.filter(/** @return {str is LH.OutputMode} */ str => {
+    if (!outputTypes.includes(str)) {
+      throw new Error(`"${str}" is not a valid 'output' value. ` + errorHint);
+    }
+    return true;
+  });
+
+  return validValues;
 }
 
 /**


Test patch:
diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js
index c7dad8b40..eb8e15902 100644
--- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js
+++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js
@@ -27,7 +27,7 @@
   const warningText = containerElement.querySelector('.lighthouse-warning-text');
 
   // Wait for warning event to be handled
-  LighthouseTestRunner._panel()._controller.addEventListener(Events.PageWarningsChanged, () => {
+  LighthouseTestRunner._panel().controller.addEventListener(Events.PageWarningsChanged, () => {
     TestRunner.addResult(`Warning Text: ${warningText.textContent}`);
     TestRunner.completeTest();
   });
diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js
index 04ce8753e..9cccf81ad 100644
--- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js
+++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js
@@ -21,7 +21,7 @@
     }
   }
 
-  TestRunner.override(LighthouseTestRunner._panel()._protocolService, 'getLocales', overrideLookupLocale, true);
+  TestRunner.override(LighthouseTestRunner._panel().protocolService, 'getLocales', overrideLookupLocale, true);
 
   const locales = ['invalid-locale', 'es'];
   function overrideLookupLocale() {
Repository: GoogleChrome/lighthouse
Pull request #12922 (2021-08-16 23:09:47)

docs(hacking): add links to buildtracker/pr-tracking
gotta put these links somewhere slightly more useful…


Patch:
diff --git a/docs/hacking-tips.md b/docs/hacking-tips.md
index 25140c015..74735a069 100644
--- a/docs/hacking-tips.md
+++ b/docs/hacking-tips.md
@@ -1,5 +1,10 @@
 A few assorted scripts and tips to make hacking on Lighthouse a bit easier
 
+# Eng team resources
+
+* [LH Build Tracker](https://lh-build-tracker.herokuapp.com/builds/limit/100) - plotted results of [build-tracker](../build-tracker.config.js) [data](../.github/workflows/ci.yml#:~:text=buildtracker)
+* [LH PR Tracking](https://paulirish.github.io/lh-pr-tracking/) - stats about open PRs, collected [daily](https://github.com/paulirish/lh-pr-tracking/blob/master/.github/workflows/update-stats.yml).
+
 ## Evaluate Lighthouse's runtime performance
 
 Lighthouse has instrumentation to collect timing data for its operations. The data is exposed at `LHR.timing.entries`.  You can generate a trace from this data for closer analysis.


Test patch:
diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js
index 4605e3587..4e475b14d 100644
--- a/lighthouse-core/test/gather/gather-runner-test.js
+++ b/lighthouse-core/test/gather/gather-runner-test.js
@@ -1044,13 +1044,26 @@ describe('GatherRunner', function() {
         'warning0',
         'warning1',
         'warning2',
+        {
+          i18nId: 'LH.IcuMessage0',
+          formattedDefault: 'warning3',
+        },
+        {
+          i18nId: 'LH.IcuMessage1',
+          formattedDefault: 'warning4',
+        },
       ];
 
       class WarningGatherer extends Gatherer {
         /** @param {LH.Gatherer.PassContext} passContext */
         afterPass(passContext) {
-          passContext.LighthouseRunWarnings.push(...runWarnings, ...runWarnings);
-          assert.strictEqual(passContext.LighthouseRunWarnings.length, runWarnings.length * 2);
+          passContext.LighthouseRunWarnings.push(
+            ...runWarnings,
+            ...runWarnings,
+            // adding one of the warnings with keys in different order
+            {formattedDefault: 'warning3', i18nId: 'LH.IcuMessage0'}
+          );
+          assert.strictEqual(passContext.LighthouseRunWarnings.length, runWarnings.length * 2 + 1);
 
           return '';
         }
Repository: prometheus/common
Pull request #450 (2023-02-21 10:40:15)

Fix and test JSON & YAML marshalling


Patch:
diff --git a/config/http_config.go b/config/http_config.go
index a836632..1bc2d06 100644
--- a/config/http_config.go
+++ b/config/http_config.go
@@ -106,7 +106,7 @@ func (tv *TLSVersion) UnmarshalJSON(data []byte) error {
 func (tv TLSVersion) MarshalJSON() ([]byte, error) {
 	for s, v := range TLSVersions {
 		if tv == v {
-			return []byte(s), nil
+			return json.Marshal(s)
 		}
 	}
 	return nil, fmt.Errorf("unknown TLS version: %d", tv)


Test patch:
diff --git a/config/tls_config_test.go b/config/tls_config_test.go
index df3aee2..a1fcda7 100644
--- a/config/tls_config_test.go
+++ b/config/tls_config_test.go
@@ -127,8 +127,88 @@ func TestInvalidTLSConfig(t *testing.T) {
 	}
 }
 
-func TestStringer(t *testing.T) {
+func TestTLSVersionStringer(t *testing.T) {
 	if s := (TLSVersion)(tls.VersionTLS13); s.String() != "TLS13" {
 		t.Fatalf("tls.VersionTLS13 string should be TLS13, got %s", s.String())
 	}
 }
+
+func TestTLSVersionMarshalYAML(t *testing.T) {
+	var tests = []struct {
+		input    TLSVersion
+		expected string
+		err      error
+	}{
+		{
+			input:    TLSVersions["TLS13"],
+			expected: "TLS13\n",
+			err:      nil,
+		},
+		{
+			input:    TLSVersions["TLS10"],
+			expected: "TLS10\n",
+			err:      nil,
+		},
+		{
+			input:    TLSVersion(999),
+			expected: "",
+			err:      fmt.Errorf("unknown TLS version: 999"),
+		},
+	}
+
+	for _, test := range tests {
+		t.Run(fmt.Sprintf("MarshalYAML(%d)", test.input), func(t *testing.T) {
+			actualBytes, err := yaml.Marshal(&test.input)
+			if err != nil {
+				if test.err == nil || err.Error() != test.err.Error() {
+					t.Fatalf("error %v, expected %v", err, test.err)
+				}
+				return
+			}
+			actual := string(actualBytes)
+			if actual != test.expected {
+				t.Fatalf("returned %s, expected %s", actual, test.expected)
+			}
+		})
+	}
+}
+
+func TestTLSVersionMarshalJSON(t *testing.T) {
+	var tests = []struct {
+		input    TLSVersion
+		expected string
+		err      error
+	}{
+		{
+			input:    TLSVersions["TLS13"],
+			expected: `"TLS13"`,
+			err:      nil,
+		},
+		{
+			input:    TLSVersions["TLS10"],
+			expected: `"TLS10"`,
+			err:      nil,
+		},
+		{
+			input:    TLSVersion(999),
+			expected: "",
+			err:      fmt.Errorf("unknown TLS version: 999"),
+		},
+	}
+
+	for _, test := range tests {
+		t.Run(fmt.Sprintf("MarshalJSON(%d)", test.input), func(t *testing.T) {
+			actualBytes, err := json.Marshal(&test.input)
+			if err != nil {
+				if test.err == nil || !strings.HasSuffix(err.Error(), test.err.Error()) {
+					t.Fatalf("error %v, expected %v", err, test.err)
+				}
+				return
+			}
+			actual := string(actualBytes)
+			if actual != test.expected {
+				t.Fatalf("returned %s, expected %s", actual, test.expected)
+			}
+		})
+	}
+}
Repository: prometheus/common
Pull request #487 (2023-05-15 08:47:54)

config: allow exposing real secret value through marshal
There are external projects out there that marshal/unmarshal the Prometheus config that has secrets. To get the real value currently such horrible workarounds are in place:
https://github.com/tkestack/kvass/blob/master/pkg/sidecar/injector.go#L175-L214

Let's add a way to get the original values through the `Secret` type to avoid such things.


Patch:
diff --git a/config/config.go b/config/config.go
index 0b91f20..3da4854 100644
--- a/config/config.go
+++ b/config/config.go
@@ -27,8 +27,16 @@ const secretToken = "<secret>"
 // Secret special type for storing secrets.
 type Secret string
 
+// MarshalSecretValue if set to true will expose Secret type
+// through the marshal interfaces. Useful for outside projects
+// that load and marshal the Prometheus config.
+var MarshalSecretValue bool = false
+
 // MarshalYAML implements the yaml.Marshaler interface for Secrets.
 func (s Secret) MarshalYAML() (interface{}, error) {
+	if MarshalSecretValue {
+		return string(s), nil
+	}
 	if s != "" {
 		return secretToken, nil
 	}
@@ -43,6 +51,9 @@ func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
 
 // MarshalJSON implements the json.Marshaler interface for Secret.
 func (s Secret) MarshalJSON() ([]byte, error) {
+	if MarshalSecretValue {
+		return json.Marshal(string(s))
+	}
 	if len(s) == 0 {
 		return json.Marshal("")
 	}


Test patch:
diff --git a/config/config_test.go b/config/config_test.go
index 1e031f5..51d2340 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -28,9 +28,11 @@ func TestJSONMarshalSecret(t *testing.T) {
 		S Secret
 	}
 	for _, tc := range []struct {
-		desc     string
-		data     tmp
-		expected string
+		desc      string
+		data      tmp
+		expected  string
+		trueValue bool
+		testYAML  bool
 	}{
 		{
 			desc: "inhabited",
@@ -39,6 +41,20 @@ func TestJSONMarshalSecret(t *testing.T) {
 			data:     tmp{"test"},
 			expected: "{\"S\":\"\\u003csecret\\u003e\"}",
 		},
+		{
+			desc:      "true value in JSON",
+			data:      tmp{"test"},
+			expected:  `{"S":"test"}`,
+			trueValue: true,
+		},
+		{
+			desc: "true value in YAML",
+			data: tmp{"test"},
+			expected: `s: test
+`,
+			trueValue: true,
+			testYAML:  true,
+		},
 		{
 			desc:     "empty",
 			data:     tmp{},
@@ -46,7 +62,15 @@ func TestJSONMarshalSecret(t *testing.T) {
 		},
 	} {
 		t.Run(tc.desc, func(t *testing.T) {
-			c, err := json.Marshal(tc.data)
+			MarshalSecretValue = tc.trueValue
+
+			var marshalFN func(any) ([]byte, error)
+			if tc.testYAML {
+				marshalFN = yaml.Marshal
+			} else {
+				marshalFN = json.Marshal
+			}
+			c, err := marshalFN(tc.data)
 			if err != nil {
 				t.Fatal(err)
 			}