apache/beam · error · RuntimeError
Unexpected value for minimum_importance argument: %r
Error message
Unexpected value for minimum_importance argument: %r
What it means
RuntimeError from DataflowApplicationClient.list_messages when minimum_importance is provided but does not match any recognized JobMessageImportance enum value. Only JOB_MESSAGE_WARNING and JOB_MESSAGE_ERROR (and the accepted defaults like JOB_MESSAGE_BASIC/DETAILED handled earlier) are mapped onto the API request. Any other string fails before the API call.
Solutions
- Use an exact Dataflow enum string, e.g. 'JOB_MESSAGE_WARNING' or 'JOB_MESSAGE_ERROR'.
- Use dataflow.JobMessageImportance enum members from the generated client rather than raw strings.
- Print accepted values and compare before calling: check the if/elif mapping in list_messages.
Example fix
// before client.list_messages(job_id, minimum_importance='warning') // after client.list_messages(job_id, minimum_importance='JOB_MESSAGE_WARNING')
Defensive patterns
Strategy: validation
Validate before calling
VALID = {'JOB_MESSAGE_WARNING', 'JOB_MESSAGE_ERROR'}
if minimum_importance not in VALID:
raise ValueError(f'minimum_importance must be one of {sorted(VALID)}, got {minimum_importance!r}') Type guard
def is_valid_importance(v) -> bool:
return isinstance(v, str) and v in {'JOB_MESSAGE_WARNING', 'JOB_MESSAGE_ERROR'} Try / catch
try:
msgs, token = client.list_messages(job_id, minimum_importance=level)
except RuntimeError as e:
if 'minimum_importance' in str(e):
level = 'JOB_MESSAGE_ERROR'
msgs, token = client.list_messages(job_id, minimum_importance=level) Prevention
- Copy enum values directly from the generated dataflow client, never by hand.
- Write the importance level as a module-level constant.
- Add a unit test covering the exact string values.
When it happens
Trigger: Calling list_messages(job_id, minimum_importance=<value>) with a misspelled or non-enum string such as 'WARNING', 'error', or an arbitrary object, where the if/elif chain doesn't match.
Common situations: Typo'd importance level in monitoring scripts; passing a lowercase variant; using an enum constant from a different library.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Can not query metrics. Job id is unknown.
- Coder for the GroupByKey operation
- CombineFn.setup and CombineFn.teardown are not supported…
- Could not find element
- Could not translate the internal step name %r.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/71bb8623b361ebf9.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:1073
request.end_time = end_time
if minimum_importance is not None:
if minimum_importance == 'JOB_MESSAGE_DEBUG':
request.minimum_importance = (
dataflow.JobMessageImportance.JOB_MESSAGE_DEBUG)
elif minimum_importance == 'JOB_MESSAGE_DETAILED':
request.minimum_importance = (
dataflow.JobMessageImportance.JOB_MESSAGE_DETAILED)
elif minimum_importance == 'JOB_MESSAGE_BASIC':
request.minimum_importance = (
dataflow.JobMessageImportance.JOB_MESSAGE_BASIC)
elif minimum_importance == 'JOB_MESSAGE_WARNING':
request.minimum_importance = (
dataflow.JobMessageImportance.JOB_MESSAGE_WARNING)
elif minimum_importance == 'JOB_MESSAGE_ERROR':
request.minimum_importance = (
dataflow.JobMessageImportance.JOB_MESSAGE_ERROR)
else:
raise RuntimeError(
'Unexpected value for minimum_importance argument: %r' %
minimum_importance)
response = self._messages_client.list_job_messages(request=request)
return response.job_messages, response.next_page_token
def job_id_for_name(self, job_name):
token = None
while True:
request = dataflow.ListJobsRequest(
project_id=self.google_cloud_options.project,
location=self.google_cloud_options.region,
page_token=token)
response = self._jobs_client.list_jobs(request)
for job in response:
if (job.name == job_name and
job.current_state in [dataflow.JobState.JOB_STATE_RUNNING,
dataflow.JobState.JOB_STATE_DRAINING]):
return job.idView on GitHub (pinned to 12126d8942)