From aaac6f6fb0b4596476e2eef2441c93d78f59393f Mon Sep 17 00:00:00 2001 From: Polina Bungina <27892524+hughcapet@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:57:09 +0200 Subject: [PATCH] Don't fail if pg_hba/pg_ident contain comment lines (#2888) yaml parser interprets such lines as null and stores it as None into the array of the parsed values, which can not be handled by write() function and crashes the whole bootstrap process. Even though it is not the proper value, it won't hurt if we just ignore it instead of failing completely. --- patroni/postgresql/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patroni/postgresql/config.py b/patroni/postgresql/config.py index 40d87f35..b15f7f23 100644 --- a/patroni/postgresql/config.py +++ b/patroni/postgresql/config.py @@ -244,9 +244,10 @@ class ConfigWriter(object): self._fd.write(line) self._fd.write('\n') - def writelines(self, lines: List[str]) -> None: + def writelines(self, lines: List[Optional[str]]) -> None: for line in lines: - self.writeline(line) + if isinstance(line, str): + self.writeline(line) @staticmethod def escape(value: Any) -> str: # Escape (by doubling) any single quotes or backslashes in given string