[ISSUE] iam.Patch value is not send when False

Open Beginner friendly
#369 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start at the iam.Patch class used by the AccountClient users.patch entry point and trace how its value is serialized into the REST request body. Reproduce the deactivation example with value=False and verify that the completed request includes the value field while still handling an unset value correctly.

Written by the indexing model from the issue text.

Description

Description
SCIM Patch class has defect when setting value to False. When value gets serialised back to REST API the value column is skipped from the body. This is because of if self.value: body['value'] = self.value logic in the Patch class.

Reproduction
Easy way to reproduce is to deactivate a User by setting active = False in Patch command

from databricks.sdk.service import iam
from databricks.sdk import AccountClient

ac = AccountClient(...)

ac.users.patch(
    id = 123,
    operations = [ iam.Patch(op=iam.PatchOp.ADD, path='active', value=False) ],
    schemas=[ iam.PatchSchema.URN_IETF_PARAMS_SCIM_API_MESSAGES_2_0_PATCH_OP ] 
)

this gets sent, notice lack of value field: body = {'Operations': {'op': 'add', 'path': 'active'}], 'schemas': ['urn:ietf:params:scim:api:messages:2.0:PatchOp'], 'id': 123}

Expected behavior
code should check if value is not None instead, so that falsy checks dont cause this behaviour

Dominant language
Python
Stars
568
Forks
217
Avg merge
1h 1m
Merged PRs (30d)
8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/databricks-sdk-py

All issues in databricks/databricks-sdk-py

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.