Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-Provided Arguments Not Being Sent in Telephony V2 Requests #285

Open
TreWilkins opened this issue Feb 15, 2025 · 0 comments · May be fixed by #286
Open

User-Provided Arguments Not Being Sent in Telephony V2 Requests #285

TreWilkins opened this issue Feb 15, 2025 · 0 comments · May be fixed by #286

Comments

@TreWilkins
Copy link

User-Provided mintime Not Being Sent in Telephony V2 Requests

Description

Arguments are not being passed in the request parameters to the telephony V2 endpoint consistently. The biggest issue is with passing back mintime, where when provided, it's not respected, this seems to be due to mintime being set to 0 by default in the get_telephony_log function, which is maintaining support for both API versions 1 and 2.

Expected Behavior

When making a request to the telephony V2 endpoint, all user-provided values that are supported by the endpoint should be included in the request parameters.

Actual Behavior

Example 1:

Most notably, mintime is incorrect in the request parameters, even though it's passed in params on function call. Other parameters are passed correctly when calling the function using **params.

params = {
    "mintime": 1724045217601,
    "maxtime": 1739597270321,
    "limit": 10,
    "next_offset": None
}

telephony_logs = admin_api.get_telephony_log(api_version=2, **params)

kwargs after get_params_from_kwargs: {'maxtime': 1739597270321, 'limit': 10}

Path: admin/v2/logs/telephony
Params sent: {'maxtime': '1739597270321', 'limit': '10', 'mintime': '1724046071273'}

Example 2:

When calling the function with kwargs=params (as shown in log_examples), none of the user-provided arguments are sent as part of the request to the endpoint. This seems to be due to kwargs being incorrectly structured—kwargs ends up as a dictionary with a single key, "kwargs", which contains the user-provided parameters. As a result, the get_params_from_kwargs function is unable to access them properly and include them in the request.

params = {
    "mintime": 1724045217601,
    "maxtime": 1739597270321,
    "limit": 10,
    "next_offset": None
}
telephony_logs = admin_api.get_telephony_log(api_version=2, kwargs=params)

kwargs after get_params_from_kwargs: {'kwargs': {'mintime': 1724045217601, 'maxtime': 1739597270321, 'limit': 10, 'next_offset': None}}

Path: admin/v2/logs/telephony
Params sent: {'mintime': '1724045902424', 'maxtime': '1739597902304'}

Steps to Reproduce

  1. Call get_telephony_log with api_version=2 and a params dictionary containing mintime.
  2. Observe the kwargs after get_params_from_kwargs.
  3. Check the request parameters being sent to the /admin/v2/logs/telephony endpoint.
  4. Notice that mintime is not what was provided when calling the get_telephony_log function , and if maxime was provided by the user, that is replaced by a default value generated by get_default_request_times()

Workarounds

Right now, there’s no direct fix without modifying either the get_telephony_log or get_params_from_kwargs functions, unless I'm using the code incorrectly—if that’s the case, please let me know.

I’m working around this issue by skipping the get_telephony_log function entirely and calling Telephony.get_telephony_logs_v2(admin_api.json_api_call, admin_api.host, **params) directly to avoid the issue. However, a proper fix would involve updating get_telephony_log to correctly handle parameters for both API versions 1 and 2.

@TreWilkins TreWilkins linked a pull request Feb 15, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant