Skip to content

Issue creating objectstorage access key without an expiry #809

Open
@sebastianelsner

Description

@sebastianelsner

Hello,

I want to create a access key without an expiry. But I keep running into an pydantic problem.

I am running this code:

    config = Configuration()
    client = DefaultApi(config)
    name = "abc"
    project_id = os.getenv("OS_PROJECT_NAME")
    cred_grp_resp = client.create_credentials_group(
        project_id, "eu01", CreateCredentialsGroupPayload(displayName=name)
    )
    acc_key_resp = client.create_access_key(
        project_id,
        "eu01",
        CreateAccessKeyPayload(),
        cred_grp_resp.credentials_group.credentials_group_id,
    )

The error I am getting is:

  File "/app/pylfc/s3.py", line 196, in create_bucket_credentials
    acc_key_resp = client.create_access_key(
  File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_validate_call.py", line 39, in wrapper_function
    return wrapper(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_validate_call.py", line 136, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/api/default_api.py", line 139, in create_access_key
    return self.api_client.response_deserialize(
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/api_client.py", line 275, in response_deserialize
    return_data = self.deserialize(response_text, response_type, content_type)
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/api_client.py", line 363, in deserialize
    return self.__deserialize(data, response_type)
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/api_client.py", line 408, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/api_client.py", line 626, in __deserialize_model
    return klass.from_dict(data)
  File "/usr/local/lib/python3.10/dist-packages/stackit/objectstorage/models/create_access_key_response.py", line 87, in from_dict
    _obj = cls.model_validate(
  File "/usr/local/lib/python3.10/dist-packages/pydantic/main.py", line 693, in model_validate
    return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for CreateAccessKeyResponse
expires
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.11/v/string_type

I seems the "CreateAccessKeyPayload" accepts an "None" expiry date, which is allowed looing at the api docs, but the CreateAccessKeyResponse requires it the field to be a string and not None.

Using the same code but setting an "expires" allows me to create the key:

    acc_key_resp = client.create_access_key(
        project_id,
        "eu01",
        CreateAccessKeyPayload(expires=datetime(2026, 1, 1)),
        cred_grp_resp.credentials_group.credentials_group_id,
    )

Asking for a fix. Kind regards, Sebastian

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions