Skip to content

Commit a2b8a56

Browse files
author
Victor Santos
committed
fix(folders): update lastSecretModified handling to ensure UTC formatting
1 parent 65f9aac commit a2b8a56

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

infisical_sdk/resources/folders.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Optional
2-
from datetime import datetime
2+
from datetime import datetime, timezone
33

44
from infisical_sdk.infisical_requests import InfisicalRequests
55
from infisical_sdk.api_types import ListFoldersResponse, SingleFolderResponse, SingleFolderResponseItem, CreateFolderResponse, CreateFolderResponseItem
@@ -15,7 +15,7 @@ def create_folder(
1515
environment_slug: str,
1616
project_id: str,
1717
path: str = "/",
18-
description: str = None) -> CreateFolderResponseItem:
18+
description: Optional[str] = None) -> CreateFolderResponseItem:
1919

2020
request_body = {
2121
"projectId": project_id,
@@ -49,12 +49,10 @@ def list_folders(
4949
}
5050

5151
if lastSecretModified is not None:
52-
# Format as RFC 3339 (ISO 8601 profile) - uses 'Z' for UTC
53-
# Workaround for the zod datetime() validation in the API
54-
iso_string = lastSecretModified.isoformat(timespec='seconds')
55-
if iso_string.endswith('+00:00'):
56-
iso_string = iso_string[:-6] + 'Z'
57-
params["lastSecretModified"] = iso_string
52+
# Convert to UTC and format as RFC 3339 with 'Z' suffix
53+
# The API expects UTC times in 'Z' format (e.g., 2023-11-07T05:31:56Z)
54+
utc_datetime = lastSecretModified.astimezone(timezone.utc) if lastSecretModified.tzinfo else lastSecretModified.replace(tzinfo=timezone.utc)
55+
params["lastSecretModified"] = utc_datetime.strftime('%Y-%m-%dT%H:%M:%SZ')
5856

5957
result = self.requests.get(
6058
path="/api/v2/folders",

0 commit comments

Comments
 (0)