cli icon indicating copy to clipboard operation
cli copied to clipboard

Need to improve error message for payload field type mismatches

Open DingzheLiTubi opened this issue 1 year ago • 1 comments

Describe the issue

given a job json payload with some field type mismatches like the example below. e.g. a string "true" provided for a field expecting bool true. when we run databricks cli actions like create job/job reset with that malformed json payload, databricks cli will return an error message Error: invalid character '\n' in string literal which does not help debugging at all.

it would be the best if databricks cli could produce more meaningful error message to help easier identifying the real issue.

Steps to reproduce the behavior

databricks jobs reset --json @/job_payload
// will return `Error: invalid character '\n' in string literal`
// hard to quickly identify the real cause of failure
cat /job_payload
{
    // omit a bunch of settings
  "job_id": xxx,
  "new_settings": {
    "name": "xxx",
    "email_notifications": {
      "on_start": [],
      "on_success": [],
      "on_failure": []
    },
    "webhook_notifications": {
      "on_start": [],
      "on_failure": []
    },
    "notification_settings": {
      "no_alert_for_skipped_runs": true,
      "no_alert_for_canceled_runs": true
    },
    "timeout_seconds": 0,
    "max_concurrent_runs": 1,
    "tasks": [
      {
        "task_key": "xxx",
        "spark_jar_task": {
          // ...
        },
        "new_cluster": {
          //...
        },
        "libraries": [
          //...
        ],
        "email_notifications": {},
        "notification_settings": {},
        "timeout_seconds": 0,
        "max_retries": 0,
        "min_retry_interval_millis": 0,
        "retry_on_timeout": "true" // here is the problem, retry_on_timeout should provide a bool true instead of string "true"
      }
    ]
  }
}

Expected Behavior

hopefully cli error message can point to the real problem in the json payload. e.g. something like string provided for `retry_on_timeout` but expecting boolean can help a lot

OS and CLI version

v0.221.1

DingzheLiTubi avatar Sep 10 '24 08:09 DingzheLiTubi

I agree; this would be great to have.

Related POC in #1171.

pietern avatar Sep 10 '24 17:09 pietern

The fix has been merged in https://github.com/databricks/cli/pull/1771 and will be released in the next CLI release

andrewnester avatar Oct 11 '24 14:10 andrewnester