<#298 pact-message return code ignored> New issue ...
# pact-python
g
#298 pact-message return code ignored New issue created by mikegeeves In message_pact.py we have:
Copy code
def write_to_pact_file(self):
        """
        Create a pact file based on provided attributes in DSL.

        Return 0 if success, 1 otherwise.

        :rtype: int
        """
        command = [
            MESSAGE_PATH,
            "update",
            json.dumps(self._messages[0]),
            "--pact-dir", self.pact_dir,
            f"--pact-specification-version={self.version}",
            "--consumer", f"{self.consumer.name}",
            "--provider", f"{self.provider.name}",
        ]

        self._message_process = Popen(command)
        self._message_process.wait()
It claims to return 0 or 1 but does not! Need to look at other implementations, how the STDERR/STDOUT is handled, this should maybe do something like Popen(command, stdout=PIPE, stderr=PIPE) and communicate instead of wait? May simply be best to just "return self._message_process.wait()" -> but then how to handle later. For reference, picked up while doing silly things with
Term("5|15|60", 60)
which is obviously invalid, causes ruby to fail, but it carries on regardless. The end result being if a previous pact file exists, it won't then fail. If one does not exist it fails because "No value provided for required pact_files" which isn't a helpful message. pact-foundation/pact-python
m
One of those, I can see how to fix, but not without potentially causing issues for people elsewhere, and best to try and fix in a way that is consistent with other languages, and who knows how they work 😄