Parameter "expand_tasks" on List job runs request seams not to be working (databricsk api)

Mildred
New Contributor

I'm setting it as True, but it doesn't return the cluster_instance info. 

Here is the function I'm using:

def get_job_runs(job_id):
    """
    Fetches job runs for a specific job from Databricks Jobs API.
    """
    headers = {
        "Authorization": f"Bearer {DATABRICKS_TOKEN}",
        "Content-Type": "application/json"
    }

    url = f"{DATABRICKS_HOST}/api/2.2/jobs/runs/list"
    data = {
        "job_id": job_id,
        "expand_tasks": True
    }

    try:
        response = session.get(url, headers=headers, params=data, verify=False)
        response.raise_for_status()
        response_data = response.json()
        runs = response_data.get("runs", [])
        return runs

    except requests.exceptions.RequestException as e:
        print(f"Error during request: {e}")
        return []
    except json.JSONDecodeError as e:
        print(f"Error decoding JSON response: {e}")
        return []
    except Exception as e:
        print(f"An unexpected error occurred: {e}")
        return []

One of the returned items:

{'job_id': 960697773932569,
 'run_id': 605591465138074,
 'creator_user_name': '62fd43e8-4d50-4e21-963e-680b2f4859c4',
 'number_in_job': 605591465138074,
 'original_attempt_run_id': 605591465138074,
 'state': {'life_cycle_state': 'TERMINATED',
  'result_state': 'SUCCESS',
  'state_message': '',
  'user_cancelled_or_timedout': False},
 'job_parameters': [{'name': 'libraries',
   'default': '',
   'value': 'h2o-pysparkling-3.4==3.44.0.1.post1 kraken-bv==0.37.7'},
  {'name': 'wg_env', 'default': '', 'value': 'prd'},
  {'name': 'wg_safra', 'default': '', 'value': '202503'}],
 'start_time': 1747408029996,
 'setup_duration': 0,
 'execution_duration': 0,
 'cleanup_duration': 0,
 'end_time': 1747431182635,
 'run_duration': 23152639,
 'trigger': 'ONE_TIME',
 'run_name': 'job_krakenbricks-data-crmx-prop-leves-pap',
 'run_page_url': 'https://7589927382780461.1.gcp.databricks.com/?o=7589927382780461#job/960697773932569/run/605591465138074',
 'run_type': 'JOB_RUN',
 'format': 'MULTI_TASK',
 'status': {'state': 'TERMINATED',
  'termination_details': {'code': 'SUCCESS',
   'type': 'SUCCESS',
   'message': ''}},
 'job_run_id': 605591465138074}