Skip to content

basic_auth_pass_is_set field should be boolean, not string to align with label studio #473

@cneedss

Description

@cneedss

Type Difference between Label Studio SDK and Label Studio

The field basic_auth_pass_is_set in the MlBackend model is currently typed as string in the OpenAPI spec used to generate the Label Studio SDK:

https://github.com/HumanSignal/label-studio-client-generator/blob/b88190a7c82661663517ccbe704ea05dd8e50e6c/fern/openapi/openapi.yaml#L8156

basic_auth_pass_is_set:
  title: Basic auth pass is set
  type: string
  readOnly: true

However, the Label Studio backend returns a boolean:

https://github.com/HumanSignal/label-studio/blob/27ec9362c4f9ba6abd56f79c9234e861cf46b494/label_studio/ml/serializers.py#L18C47-L19C1

def get_basic_auth_pass_is_set(self, obj):
    return bool(obj.basic_auth_pass)

Mismatch Triggers Errors

Here's example code that fails due to the type mismatch.

from label_studio_sdk import LabelStudio

ls = LabelStudio(
    base_url="https://your.labelstudio.instance",
    api_key="your-api-key",
)

ls.ml.list(project=your-project-id)  # <- triggers error because backend includes `basic_auth_pass_is_set` as a boolean

Error Traceback

pydantic_core._pydantic_core.ValidationError: 2 validation errors for list[MlBackend]
0.basic_auth_pass_is_set
  Input should be a valid string [type=string_type, input_value=False, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.11/v/string_type
0.extra_params
  Input should be a valid dictionary [type=dict_type, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/dict_type

Where the Related Code Appears in the SDK Code

1. SDK definition (generated):

basic_auth_pass_is_set: typing.Optional[str] = None

basic_auth_pass_is_set: typing.Optional[str] = None

2. Runtime error in SDK occurs during this type check as the MlCreateResponse includes the expectation that the basic_auth_pass_is_set is as string. The Label Studio Server response has basic_auth_pass_is_set as as boolean, not as string:

if 200 <= _response.status_code < 300:
    return typing.cast(
        MlCreateResponse,
        parse_obj_as(
            type_=MlCreateResponse,  # type: ignore
            object_=_response.json(),
        ),
    )

Proposed Fix

Update the OpenAPI spec field to:

basic_auth_pass_is_set:
  title: Basic auth pass is set
  type: boolean
  readOnly: true

This should regenerate the SDK with the correct type based on what I've read:

basic_auth_pass_is_set: typing.Optional[bool] = None

Additional Note

I'm not 100% sure whether the original intent was for this to be a string or a boolean, but based on the actual behavior of the backend, boolean seems to be the correct intended type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions