Skip to content

Accessing client_stream_profile settings in UDP stream app results in exception #5

@njferrant

Description

@njferrant

Issue:

When calling session.config.config.traffic_profiles[0].applications[0].stateless_stream.client_stream_profile the following exception occurs:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 361, in get_by_link
    field = self.link_based_request(link.name, "GET",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 302, in <lambda>
    c.link_based_request = lambda self, link_name, method, return_type=None, body=None, query=[]: cls.link_based_request(self, link_name, method, return_type, body, query)
                                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 507, in link_based_request
    response = self.api_client.call_api(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 385, in call_api
    return self.__retry(lambda: self.__call_api(method, url, header_params,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 127, in __retry
    result = request_func()
             ^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 385, in <lambda>
    return self.__retry(lambda: self.__call_api(method, url, header_params,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 359, in __call_api
    return DynamicModel.dynamic_wrapper(self.response_deserialize(
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 425, in response_deserialize
    return_data = self.deserialize(response_text, response_type, content_type)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 527, in deserialize
    return self.__deserialize(data, response_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 581, in __deserialize
    return self.__deserialize_model(data, klass)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 902, in __deserialize_model
    return klass.from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/cyperf/models/stream_profile.py", line 92, in from_dict
    _obj = cls.model_validate({
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/cyperf-rest-client/.venv/lib/python3.11/site-packages/pydantic/main.py", line 705, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for StreamProfile
payloadType
  Input should be 'RANDOM', 'PSEUDORANDOM' or '<nil>' [type=enum, input_value='null', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/enum

It looks like the API is returning null for the StreamPayloadType (in client StreamProfile), which is being converted to the string 'null'. StreamPayloadType is expecting '<nil>', thus the exception.

Versions:

CyPerf Controller: 7.0 (build 14934)
cyperf-api-wrapper: commit c8e07832bf2befa4f3c1b179a422c0bfb3f2d69c
python: 3.11

Workaround:

I'm doing the following (shown as a diff patch):

--- stream_payload_type.py.orig 2025-09-08 13:22:09
+++ stream_payload_type.py      2025-09-08 13:22:23
@@ -29,7 +29,7 @@
     """
     RANDOM = 'RANDOM'
     PSEUDORANDOM = 'PSEUDORANDOM'
-    LESS_THAN_NIL_GREATER_THAN = '<nil>'
+    LESS_THAN_NIL_GREATER_THAN = 'null'
 
     @classmethod
     def from_json(cls, json_str: str) -> Self:

Metadata

Metadata

Assignees

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