nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: XLSForm/pyxform
Pull request #436 (2020-03-04 16:18:48)

small patch to support another java version string for 9-internal
when building an onadata docker image, it picked up a java version which fails the logic, preventing any form uploads.


Patch:
diff --git a/pyxform/validators/odk_validate/__init__.py b/pyxform/validators/odk_validate/__init__.py
index 5cd809f..d981464 100644
--- a/pyxform/validators/odk_validate/__init__.py
+++ b/pyxform/validators/odk_validate/__init__.py
@@ -75,6 +75,8 @@ def check_java_version():
     java_version = re.findall(r"\"(.+?)\"", java_version_str)[0]
     if "." in java_version:
         major, minor, _ = java_version.split(".")
+    elif "-" in java_version:
+        major, minor = int(java_version.split("-")[0]), 0
     else:
         major, minor = int(java_version), 0
     if not ((int(major) == 1 and int(minor) >= 8) or int(major) >= 8):


Test patch:
diff --git a/pyxform/tests_v1/test_validators.py b/pyxform/tests_v1/test_validators.py
index a994f67..0062f5f 100644
--- a/pyxform/tests_v1/test_validators.py
+++ b/pyxform/tests_v1/test_validators.py
@@ -32,6 +32,10 @@ OPENJDK_13 = """openjdk version "13" 2019-09-17
 OpenJDK Runtime Environment (build 13+33)
 OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
 """
+OPENJDK_9_INT = """openjdk version "9-internal"
+OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
+OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
+"""
 
 
 class TestValidators(TestCase):
@@ -68,3 +72,7 @@ class TestValidators(TestCase):
         with patch(mock_func) as mock_popen:
             mock_popen.return_value = (0, False, "", OPENJDK_13)
             check_java_version()
+
+        with patch(mock_func) as mock_popen:
+            mock_popen.return_value = (0, False, "", OPENJDK_9_INT)
+            check_java_version()
Repository: XLSForm/pyxform
Pull request #457 (2020-07-13 13:43:19)

Triggers referring to hidden question will produce an error.
Closes #
#452 
#### Why is this the best possible solution? Were any other approaches considered?
The simplest one.
#### What are the regression risks?
None.
#### Does this change require updates to documentation? If so, please file an issue [here](https://github.com/XLSForm/xlsform.github.io) and include the link below.
None.
#### Before submitting this PR, please make sure you have:
- [x] included test cases for core behavior and edge cases in `tests_v1`
- [x] run `nosetests` and verified all tests pass
- [x] run `black pyxform` to format code
- [x] verified that any code or assets from external sources are properly credited in comments


Patch:
diff --git a/pyxform/question.py b/pyxform/question.py
index c1633e1..02e7f19 100644
--- a/pyxform/question.py
+++ b/pyxform/question.py
@@ -32,6 +32,16 @@ class Question(SurveyElement):
 
     def xml_control(self):
         if ("calculate" in self.bind or self.trigger) and not (self.label or self.hint):
+            nested_setvalues = self.get_root().get_setvalues_for_question_name(
+                self.name
+            )
+            if nested_setvalues:
+                for setvalue in nested_setvalues:
+                    msg = (
+                        "Trigger was added for ${%s} that refers to hidden question. This is not allowed."
+                        % setvalue[0]
+                    )
+                    raise PyXFormError(msg)
             return None
 
         xml_node = self.build_xml()


Test patch:
diff --git a/pyxform/tests_v1/test_trigger.py b/pyxform/tests_v1/test_trigger.py
index 70155be..6da047f 100644
--- a/pyxform/tests_v1/test_trigger.py
+++ b/pyxform/tests_v1/test_trigger.py
@@ -158,6 +158,22 @@ class TriggerSetvalueTests(PyxformTestCase):
             ],
         )
 
+    def test_trigger_refer_to_hidden_node_ref_gives_error(self):
+        self.assertPyxformXform(
+            name="trigger-invalid-ref",
+            md="""
+            | survey |           |        |                      |         |             |
+            |        | type      | name   | label                | trigger | calculation |
+            |        | calculate | one    |                      |         | 5 + 4       |
+            |        | calculate | one-ts |                      | ${one}  | now()       |
+            |        | note      | note   | timestamp: ${one-ts} |         |             |
+            """,
+            errored=True,
+            error__contains=[
+                "Trigger was added for ${one-ts} that refers to hidden question. This is not allowed."
+            ],
+        )
+
     def test_handling_trigger_column_in_group(self):
         md = """
         | survey |             |      |                    |             |         |