Skip to content

[ISSUE] JobsAPI.create in v0.4.0 does not serialize the access_control_list correctly #270

@pspeter

Description

@pspeter

Description
The JobsAPI.create() method does not transform access_control_list into a list of dicts, so the request fails when trying to serialize it to JSON.

Reproduction

w = WorkspaceClient()
w.jobs.create(access_control_list=[AccessControlRequest()])

Stacktrace:

  [...]
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/databricks/sdk/service/jobs.py", line 2888, in create
    json = self._api.do('POST', '/api/2.1/jobs/create', body=body)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/databricks/sdk/core.py", line 949, in do
    response = self._session.request(method,
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/models.py", line 371, in prepare
    self.prepare_body(data, files, json)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AccessControlRequest is not JSON serializable

Other Information

  • Version: 0.4.0

Metadata

Metadata

Assignees

No one assigned

    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