Skip to content

Commit

Permalink
fix: don't delete non-action enum data if it doesn't have `replaced_b…
Browse files Browse the repository at this point in the history
…y` (#1014)

Co-authored-by: Viraj <[email protected]>
  • Loading branch information
tushar-composio and angrybayblade authored Dec 16, 2024
1 parent 502eb8a commit 05e8a39
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/composio/client/enums/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from composio.exceptions import ComposioSDKError
from composio.storage.base import LocalStorage

from .base import EnumStringNotFound, SentinalObject
from .base import ActionData, EnumStringNotFound, SentinalObject


DataT = t.TypeVar("DataT", bound=LocalStorage)
Expand Down Expand Up @@ -119,11 +119,15 @@ def load(self) -> DataT:
data = self.storage.load(self.storage_path)
# HACK: if 'replaced_by' field is not present, delete this cached file
# as it is outdated.
if hasattr(data, "replaced_by"):
self._data = data
return self._data
if isinstance(data, ActionData):
if hasattr(data, "replaced_by"):
self._data = data # type: ignore
return self._data # type: ignore

self.storage_path.unlink()

self.storage_path.unlink()
self._data = data
return self._data

# Try to fetch from runtime
runtime_data = self.load_from_runtime()
Expand Down

0 comments on commit 05e8a39

Please sign in to comment.