Coder Social home page Coder Social logo

Comments (2)

Integralist avatar Integralist commented on August 19, 2024

Hi @gsbiel

Thanks for raising this issue. Looks like there's a problem with the code-generation process for this API client.

The error is:

fastly.exceptions.ApiValueError: Invalid value for `scope` (global:read global), must be one of ['global', 'purge_select', 'purge_all', 'global:read']

Looking at the documented API https://developer.fastly.com/reference/api/auth-tokens/user/#data-model it seems scope can be assigned a "space-delimited list of authorization scope", which it is in your case (based on the error: it's set to global:read global) but the generated code for the API client thinks that it should be a single value (based on the error: must be one of ['global', 'purge_select', 'purge_all', 'global:read']).

I'll open a ticket internally to track this.

from fastly-py.

gsbiel avatar gsbiel commented on August 19, 2024

Hi @Integralist
Thank you very much for your support on this :)

I tried to workaround that error by configuring my Fastly API key to have only a single value as scope, but no success.
In that case, I setup only global:read scope, but got another error:

Traceback (most recent call last):
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
    allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model/token_response_all_of.py", line 191, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 184, in __setattr__
    self[attr] = value
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 509, in __setitem__
    self.set_attribute(name, value)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 156, in set_attribute
    value = validate_and_convert_types(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1448, in attempt_convert_item
    raise get_type_error(input_value, path_to_item, valid_classes,
fastly.exceptions.ApiTypeError: Invalid type for variable 'expires_at'. Required value type is str and passed type was NoneType at ['received_data'][0]['expires_at']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/gasper/Documents/hearst/experiments/audit_fastly_users/main.py", line 74, in <module>
    main()
  File "/home/gasper/Documents/hearst/experiments/audit_fastly_users/main.py", line 54, in main
    customer_tokens = list_customer_tokens(fastly_api_key, customer_id)
  File "/home/gasper/Documents/hearst/experiments/audit_fastly_users/main.py", line 33, in list_customer_tokens
    api_response = api_instance.list_tokens_customer(customer_id)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api/tokens_api.py", line 850, in list_tokens_customer
    return self.list_tokens_customer_endpoint.call_with_http_info(**kwargs)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 872, in call_with_http_info
    return self.api_client.call_api(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 427, in call_api
    return self.__call_api(resource_path, method,
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 236, in __call_api
    return_data = self.deserialize(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 341, in deserialize
    deserialized_data = validate_and_convert_types(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
    input_value[index] = validate_and_convert_types(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
    raise conversion_exc
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
    return deserialize_model(input_value, valid_class,
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model/token_response.py", line 223, in _from_openapi_data
    composed_info = validate_get_composed_info(
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
    allof_instances = get_allof_instances(self, model_args, constant_args)
  File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
    raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'TokenResponseAllOf'. The input data was invalid for the allOf schema 'TokenResponseAllOf' in the composed schema 'TokenResponse'. Error=Invalid type for variable 'expires_at'. Required value type is str and passed type was NoneType at ['received_data'][0]['expires_at']

from fastly-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.