Description
Description
When calling the stackit.ske.api.DefaultApi.list_clusters
method, a pydantic.ValidationError
is raised during the deserialization of the API response. The error specifically points to the maintenance.timeWindow.end
and maintenance.timeWindow.start
fields, indicating that the year '0000' is out of range for a valid datetime object.
This suggests that the STACKIT SKE API is returning malformed datetime strings (e.g., 0000-01-01T06:00:00+02:00
) for the maintenance windows of certain clusters, which Pydantic's strict datetime parsing cannot handle.
Steps to reproduce
-
Ensure you have the
stackit-sdk-python
installed and configured with valid credentials. -
Use the following Python code snippet (or a similar one that iterates through projects and calls
list_clusters
):from stackit.ske.api.default_api import DefaultApi as ske_api from stackit.resourcemanager.api.default_api import DefaultApi as resource_manager_api from stackit.core.configuration import Configuration import os def main(): config = Configuration(service_account_key_path="path/to/.stackit/credentials.json") resource_manager_client = resource_manager_api(config) ske_client = ske_api(config) # Replace with your actual container_parent_id projects_list = resource_manager_client.list_projects(container_parent_id="1231241-bcd8-123123-123123-123123") for project in projects_list.items: if project.lifecycle_state == "ACTIVE": print(f"Checking project: {project.name} ({project.project_id})") try: # The error occurs here for specific projects/clusters cluster_list = ske_client.list_clusters(region="eu01", project_id=project.project_id) if cluster_list.items: for cluster in cluster_list.items: print(f" - Found cluster: {cluster.name}") else: print(" No clusters found.") except Exception as e: print(f" Error processing project {project.name}: {e}") if __name__ == "__main__": main()
-
Run the script. The
ValidationError
should occur when attempting to list clusters for a project that has a cluster with the described malformedmaintenance.timeWindow
data.
Expected Behavior:
The list_clusters
method should successfully return a list of cluster objects without raising a ValidationError
. Datetime fields in the API response should contain valid dates that can be parsed by standard datetime libraries and Pydantic.
Actual Behavior:
A pydantic.ValidationError
is raised, preventing the successful retrieval of cluster information for projects where the maintenance.timeWindow
fields contain the year '0000'.
Environment:
- Python Version: 3.11.x
- stackit-sdk-python version: version = "1.0.0"