diff --git a/databricks/sdk/dbutils.py b/databricks/sdk/dbutils.py index afd57d8b5..be12e5d17 100644 --- a/databricks/sdk/dbutils.py +++ b/databricks/sdk/dbutils.py @@ -171,8 +171,10 @@ class _TaskValuesUtil: def get(self, taskKey: str, key: str, default: any = None, debugValue: any = None) -> None: """ - Returns the latest task value that belongs to the current job run + Returns `debugValue` if present, throws an error otherwise as this implementation is always run outside of a job run """ + if debugValue is None: + raise ValueError('No debug value set for task value, when outside of job run') return debugValue def set(self, key: str, value: any) -> None: diff --git a/tests/test_dbutils.py b/tests/test_dbutils.py index c1a349f95..ebd9bbc72 100644 --- a/tests/test_dbutils.py +++ b/tests/test_dbutils.py @@ -216,3 +216,11 @@ def test_jobs_task_values_get(dbutils): dbutils.jobs.taskValues.set('key', 'value') assert dbutils.jobs.taskValues.get('taskKey', 'key', debugValue='debug') == 'debug' + + +def test_jobs_task_values_get_throws(dbutils): + try: + dbutils.jobs.taskValues.get('taskKey', 'key') + assert False + except ValueError as e: + assert str(e) == 'No debug value set for task value, when outside of job run'