nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: metallb/metallb
Pull request #1778 (2023-01-13 14:30:05)

Wipe out the loadbalancers assigned to a service if they are not valid
Currently, when metallb receives a service with malformed lb ips and it's not able to determine the ip family, it errors out and reprocesses the service.

Here if the lb part of the status is invalid we just wipe it and let the assignement logic add a new ip. This prevents malformed services to cause infinite loops and helps in recovering the service.

Fixes https://github.com/metallb/metallb/issues/1431

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>


fedepaol: Fixes https://github.com/metallb/metallb/issues/1431
auxworker: I hope this gets merged soon, I havent tested it however

Patch:
diff --git a/controller/service.go b/controller/service.go
index ef1272d7..92e8eeeb 100644
--- a/controller/service.go
+++ b/controller/service.go
@@ -72,7 +72,6 @@ func (c *controller) convergeBalancer(l log.Logger, key string, svc *v1.Service)
 		if err != nil {
 			level.Error(l).Log("event", "clearAssignment", "reason", "nolbIPsIPFamily", "msg", "Failed to retrieve lbIPs family")
 			c.client.Errorf(svc, "nolbIPsIPFamily", "Failed to retrieve LBIPs IPFamily for %q: %s", lbIPs, err)
-			return true
 		}
 		clusterIPsIPFamily, err := ipfamily.ForService(svc)
 		if err != nil {
@@ -82,7 +81,8 @@ func (c *controller) convergeBalancer(l log.Logger, key string, svc *v1.Service)
 		}
 		// Clear the lbIP if it has a different ipFamily compared to the clusterIP.
 		// (this should not happen since the "ipFamily" of a service is immutable)
-		if lbIPsIPFamily != clusterIPsIPFamily {
+		if lbIPsIPFamily != clusterIPsIPFamily ||
+			lbIPsIPFamily == ipfamily.Unknown {
 			c.clearServiceState(key, svc)
 			lbIPs = []net.IP{}
 		}


Test patch:
diff --git a/controller/controller_test.go b/controller/controller_test.go
index c558d700..31940455 100644
--- a/controller/controller_test.go
+++ b/controller/controller_test.go
@@ -845,6 +845,24 @@ func TestControllerMutation(t *testing.T) {
 				Status: statusAssigned([]string{"19.20.21.0"}),
 			},
 		},
+		{
+			desc: "simple LoadBalancer, ips already assigned but can't determine family",
+			in: &v1.Service{
+				Spec: v1.ServiceSpec{
+					Type:       "LoadBalancer",
+					ClusterIPs: []string{"1.2.3.4"},
+				},
+				Status: statusAssigned([]string{"1.2.3.0", "1.2.3.1", "1.2.3.2"}),
+			},
+			want: &v1.Service{
+				Spec: v1.ServiceSpec{
+					ClusterIPs: []string{"1.2.3.4"},
+					Type:       "LoadBalancer",
+				},
+				Status: statusAssigned([]string{"1.2.3.0"}),
+			},
+			wantErr: true,
+		},
 	}
 
 	for i := 0; i < 100; i++ {
Repository: FHIR/sushi
Pull request #528 (2020-07-14 17:56:39)

Fix hidden files
This fixes the concerns with hidden files raised in this comment: https://github.com/FHIR/sushi/pull/523#issuecomment-658308251.


Patch:
diff --git a/src/ig/IGExporter.ts b/src/ig/IGExporter.ts
index 068b63c..b638243 100644
--- a/src/ig/IGExporter.ts
+++ b/src/ig/IGExporter.ts
@@ -420,7 +420,7 @@ export class IGExporter {
                 generation: page.fileType === 'md' ? 'markdown' : 'html'
               });
             }
-          } else {
+          } else if (!junk.is(path.basename(pagePath))) {
             invalidFileTypeIncluded = true;
           }
         });
@@ -463,7 +463,7 @@ export class IGExporter {
             path.join(outputPageContentPath, contentFile)
           );
           const fileType = contentFile.slice(contentFile.lastIndexOf('.') + 1);
-          if (!(fileType === 'md' || fileType === 'xml')) {
+          if (!(fileType === 'md' || fileType === 'xml') && !junk.is(path.basename(contentFile))) {
             invalidFileTypeIncluded = true;
           }
         }


Test patch:
diff --git a/test/ig/IGExporter.IG.test.ts b/test/ig/IGExporter.IG.test.ts
index 23d521b..5e39a04 100644
--- a/test/ig/IGExporter.IG.test.ts
+++ b/test/ig/IGExporter.IG.test.ts
@@ -1363,6 +1363,7 @@ describe('IGExporter', () => {
         path.resolve(fixtures, 'ig-data'),
         false
       );
+      loggerSpy.reset();
     });
 
     it('should avoid copying over extra system files', () => {
@@ -1372,6 +1373,7 @@ describe('IGExporter', () => {
       expect(imagesDir).toEqual(['Shorty.png']);
       const pageContentDir = fs.readdirSync(path.join(tempOut, 'input', 'pagecontent'));
       expect(pageContentDir).toEqual(['index.md']);
+      expect(loggerSpy.getAllMessages('warn')).toHaveLength(0);
       const includesDir = fs.readdirSync(path.join(tempOut, 'input', 'includes'));
       expect(includesDir).toEqual(['menu.xml']);
     });
Repository: FHIR/sushi
Pull request #622 (2020-10-01 20:03:37)

Fix nested ad hoc extensions
Fixes https://github.com/FHIR/sushi/issues/621.

See the issue for an example of the bug. To test this, you can run that example on `master` and observe the errors, and note that no `extensions` are created within `item` objects on the instance. Then, run this example on this branch, and notice that those errors go away (still expect to see other errors and warnings related to elements not having correct cardinality, please excuse those), and the extensions are added to the `item` objects.

cmoesel: This was a super simple fix.  I'm merging w/ one review.

Patch:
diff --git a/src/fhirtypes/StructureDefinition.ts b/src/fhirtypes/StructureDefinition.ts
index 5dfee4d..bf5256f 100644
--- a/src/fhirtypes/StructureDefinition.ts
+++ b/src/fhirtypes/StructureDefinition.ts
@@ -472,7 +472,7 @@ export class StructureDefinition {
       // Allow for adding extension elements to the instance that are not on the SD
       if (!currentElement && pathPart.base === 'extension') {
         // Get extension element (if currentPath is A.B.extension[C], get A.B.extension)
-        const extensionPath = `${previousPath ? `${previousPath}'.'` : ''}${pathPart.base}`;
+        const extensionPath = `${previousPath ? `${previousPath}.` : ''}${pathPart.base}`;
         const extensionElement = this.findElementByPath(extensionPath, fisher);
         // Get the extension being referred to
         const extension = fisher.fishForMetadata(pathPart.brackets[0]);


Test patch:
diff --git a/test/fhirtypes/StructureDefinition.test.ts b/test/fhirtypes/StructureDefinition.test.ts
index 1c0fcdb..c3b85c1 100644
--- a/test/fhirtypes/StructureDefinition.test.ts
+++ b/test/fhirtypes/StructureDefinition.test.ts
@@ -1166,6 +1166,22 @@ describe('StructureDefinition', () => {
       expect(respRate.elements.length).toBe(originalLength + 5);
     });
 
+    it('should allow setting nested arbitrary defined extensions', () => {
+      const originalLength = respRate.elements.length;
+      const { assignedValue, pathParts } = respRate.validateValueAtPath(
+        'extension[0].extension[patient-mothersMaidenName].value[x]',
+        'foo',
+        fisher
+      );
+      expect(assignedValue).toBe('foo');
+      expect(pathParts.length).toBe(3);
+      expect(pathParts[1]).toEqual({
+        base: 'extension',
+        brackets: ['patient-mothersMaidenName', '0']
+      });
+      expect(respRate.elements.length).toBe(originalLength + 9);
+    });
+
     it('should not allow setting arbitrary undefined extensions', () => {
       expect(() => {
         respRate.validateValueAtPath('extension[fake-extension].value[x]', 'foo', fisher);
Repository: FHIR/sushi
Pull request #669 (2020-11-16 17:39:48)

Log dependencies individually when extracted from IG
When a configuration is extracted from an ImplementationGuide resource, info messages are logged for the elements of the configuration. The dependencies array may have many elements. To avoid an overly-long message, each element of the array is logged separately.


Patch:
diff --git a/src/import/loadConfigurationFromIgResource.ts b/src/import/loadConfigurationFromIgResource.ts
index 0b0e4e5..9fb0495 100644
--- a/src/import/loadConfigurationFromIgResource.ts
+++ b/src/import/loadConfigurationFromIgResource.ts
@@ -66,7 +66,15 @@ export function loadConfigurationFromIgResource(igRoot: string): Configuration |
       FSHOnly: true
     };
     logger.info(`Extracting FSHOnly configuration from ${igPath}:`);
-    Object.entries(config).forEach(e => logger.info(`  ${e[0]}: ${JSON.stringify(e[1])}`));
+    Object.entries(config).forEach(e => {
+      if (Array.isArray(e[1])) {
+        e[1].forEach((sub: any, i: number) => {
+          logger.info(`  ${e[0]}[${i}]: ${JSON.stringify(sub)}`);
+        });
+      } else {
+        logger.info(`  ${e[0]}: ${JSON.stringify(e[1])}`);
+      }
+    });
     return config;
   }
   return null;


Test patch:
diff --git a/test/import/loadConfigurationFromIgResource.test.ts b/test/import/loadConfigurationFromIgResource.test.ts
index a9f8d15..4670053 100644
--- a/test/import/loadConfigurationFromIgResource.test.ts
+++ b/test/import/loadConfigurationFromIgResource.test.ts
@@ -48,11 +48,14 @@ describe('loadConfigurationFromIgResource', () => {
     );
     expect(loggerSpy.getMessageAtIndex(1, 'info')).toEqual('  canonical: "http://example.org"');
     expect(loggerSpy.getMessageAtIndex(2, 'info')).toEqual('  version: "1.0.0"');
-    expect(loggerSpy.getMessageAtIndex(3, 'info')).toEqual('  fhirVersion: ["4.0.1"]');
+    expect(loggerSpy.getMessageAtIndex(3, 'info')).toEqual('  fhirVersion[0]: "4.0.1"');
     expect(loggerSpy.getMessageAtIndex(4, 'info')).toEqual(
-      '  dependencies: [{"packageId":"foo.bar","version":"1.2.3"},{"packageId":"bar.foo","version":"current"}]'
+      '  dependencies[0]: {"packageId":"foo.bar","version":"1.2.3"}'
     );
-    expect(loggerSpy.getMessageAtIndex(5, 'info')).toEqual('  FSHOnly: true');
+    expect(loggerSpy.getMessageAtIndex(5, 'info')).toEqual(
+      '  dependencies[1]: {"packageId":"bar.foo","version":"current"}'
+    );
+    expect(loggerSpy.getMessageAtIndex(6, 'info')).toEqual('  FSHOnly: true');
   });
 
   it('should extract an XML configuration with a url and dependencies', () => {
Repository: FHIR/sushi
Pull request #683 (2020-11-30 18:40:21)

Update FshCode toString to support spaces in codes
This PR updates the `toString` method of `FshCode` to support codes that have spaces in them. Codes with spaces should be wrapped in quotation marks. I also added tests to test the `toString` function, which includes a test that checks for codes with spaces. That particular test would not pass without the update to the `toString` function. Since there were not tests for FshCode to start with, I haven't tested every function in the class, but I can add those if we think that's something we need and I should include now.

Note that using these changes with GoFSH will also allow us to correctly generate FSH from codes that had spaces in them, which is where we originally noticed this issue.

cmoesel: Woah. Sorry about all that weird assign/unassign stuff.

Patch:
diff --git a/src/fshtypes/FshCode.ts b/src/fshtypes/FshCode.ts
index 7add8a6..53b7a55 100644
--- a/src/fshtypes/FshCode.ts
+++ b/src/fshtypes/FshCode.ts
@@ -7,7 +7,7 @@ export class FshCode extends FshEntity {
   }
 
   toString(): string {
-    const str = `${this.system ?? ''}#${this.code}`;
+    const str = `${this.system ?? ''}#${this.code.includes(' ') ? `"${this.code}"` : this.code}`;
     return this.display ? `${str} "${this.display}"` : str;
   }
 


Test patch:
diff --git a/test/fshtypes/FshCode.test.ts b/test/fshtypes/FshCode.test.ts
new file mode 100644
index 0000000..edee649
--- /dev/null
+++ b/test/fshtypes/FshCode.test.ts
@@ -0,0 +1,44 @@
+import { FshCode } from '../../src/fshtypes';
+
+describe('FshCode', () => {
+  describe('#constructor', () => {
+    it('should set the properties correctly', () => {
+      const p = new FshCode('my-code', 'http://important.com', 'My Important Code');
+      expect(p.code).toBe('my-code');
+      expect(p.system).toBe('http://important.com');
+      expect(p.display).toBe('My Important Code');
+    });
+  });
+
+  describe('#toString', () => {
+    it('should return string for basic code', () => {
+      const code = new FshCode('my-code');
+      const result = code.toString();
+      expect(result).toEqual('#my-code');
+    });
+
+    it('should return string for code with system', () => {
+      const code = new FshCode('my-code', 'http://foo.com');
+      const result = code.toString();
+      expect(result).toEqual('http://foo.com#my-code');
+    });
+
+    it('should return string for code with display', () => {
+      const code = new FshCode('my-code', null, 'Display');
+      const result = code.toString();
+      expect(result).toEqual('#my-code "Display"');
+    });
+
+    it('should return string for code with system and display', () => {
+      const code = new FshCode('my-code', 'http://foo.com', 'Display');
+      const result = code.toString();
+      expect(result).toEqual('http://foo.com#my-code "Display"');
+    });
+
+    it('should return string for code with code with spaces', () => {
+      const code = new FshCode('my spacey code');
+      const result = code.toString();
+      expect(result).toEqual('#"my spacey code"');
+    });
+  });
+});