Skip to content

feat: add support for nullable parameters in API calls in python#1098

Closed
ChiragAgg5k wants to merge 2 commits intomasterfrom
PLA-3148
Closed

feat: add support for nullable parameters in API calls in python#1098
ChiragAgg5k wants to merge 2 commits intomasterfrom
PLA-3148

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

What does this PR do?

currently python sdk filters out all None values from api requests. but attributes like default can be nullable, and hence should not be filtered out

Test Plan

Screenshot 2025-07-01 at 6 17 30 PM

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

yes.

@ChiragAgg5k ChiragAgg5k requested a review from Copilot July 1, 2025 12:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Python SDK’s request builder so that parameters marked as nullable in the API schema aren’t dropped when they’re explicitly set to None.

  • Added a nullable_params argument to Client.call and updated the filtering logic
  • Updated the low-level request template to pass nullable parameters through
  • Populated nullable_params in the parameter-gathering template
Comments suppressed due to low confidence (3)

templates/python/package/client.py.twig:52

  • The new nullable_params argument should be documented (e.g., in a docstring or comment) to explain that it is a list of parameter names that should not have their None values filtered out.
    def call(self, method, path='', headers=None, params=None, response_type='json', nullable_params=None):

templates/python/base/requests/api.twig:8

  • Passing nullable_params as a positional argument can shift the meaning of subsequent positional parameters; consider using nullable_params=nullable_params as a named argument to avoid breaking callers if the signature changes.
        }, api_params, nullable_params{% if method.type == 'webAuth' %}, response_type='location'{% endif %})

templates/python/package/client.py.twig:63

  • We should add or update unit tests to cover the new behavior: verify that parameters listed in nullable_params remain in the request payload even when their value is None.
        params = {k: v for k, v in params.items() if v is not None or k in nullable_params}

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 this pull request may close these issues.

2 participants