diff --git a/changelog.d/20261106_120000_kurtmckee_local_server_info_toctou.rst b/changelog.d/20261106_120000_kurtmckee_local_server_info_toctou.rst new file mode 100644 index 000000000..cc832c861 --- /dev/null +++ b/changelog.d/20261106_120000_kurtmckee_local_server_info_toctou.rst @@ -0,0 +1,5 @@ +Fixed +----- + +- ``LocalGlobusConnectServer.info_dict`` can no longer raise ``FileNotFoundError`` + if the ``info.json`` file is removed while it is being loaded. (:pr:`NUMBER`) diff --git a/src/globus_sdk/local_endpoint/server/endpoint.py b/src/globus_sdk/local_endpoint/server/endpoint.py index 753d5e33a..25bee20c5 100644 --- a/src/globus_sdk/local_endpoint/server/endpoint.py +++ b/src/globus_sdk/local_endpoint/server/endpoint.py @@ -37,7 +37,7 @@ def info_dict(self) -> dict[str, t.Any] | None: Server on the container host. """ if self._loaded_info is None: - if self.info_path.is_file(): + try: with open(self.info_path, encoding="utf-8") as fp: try: parsed_data = json.load(fp) @@ -46,6 +46,8 @@ def info_dict(self) -> dict[str, t.Any] | None: else: if isinstance(parsed_data, dict): self._loaded_info = t.cast(t.Dict[str, t.Any], parsed_data) + except (FileNotFoundError, IsADirectoryError): + pass return self._loaded_info @info_dict.deleter