apache/beam · error · ValueError
publish_time_field must be a non-empty field name.
Error message
publish_time_field must be a non-empty field name.
What it means
read_from_pubsub validates publish_time_field: it must be a non-empty field name because it becomes a column on each output Row carrying the message's publish time; an empty string would create an unnamed, unqueryable field.
Solutions
- Remove the publish_time_field key entirely to disable it
- Or provide an actual field name like publish_time
- Strip/sanitize the config value before passing it
Example fix
// before publish_time_field: '' // after publish_time_field: publish_time
Defensive patterns
Strategy: validation
Validate before calling
if publish_time_field is not None and not publish_time_field.strip():
publish_time_field = None # or raise Type guard
def is_valid_field_name(name):
return isinstance(name, str) and bool(name.strip()) Try / catch
try:
read_from_pubsub(..., publish_time_field=ptf)
except ValueError as e:
if 'non-empty field name' in str(e):
ptf = None # disable the feature Prevention
- Omit the key entirely to disable, never set it to ''
- Strip config strings before use
- Treat empty-string configs as absent during normalization
When it happens
Trigger: publish_time_field='' or ' ' passed to read_from_pubsub (is not None passes, but .strip() is empty).
Common situations: YAML key publish_time_field: '' left empty after editing config; user intends to disable it but leaves an empty string instead of removing the key.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Either a topic or subscription must be provided.
- Either data (%r) or attributes (%r) must be set.
- Invalid PubSub project name: %r.
- Only one of topic or subscription should be provided.
- PubSub subscription must be in the form "projects/
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3a6ad0a7c36939c8.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/yaml_io.py:392
uses message publishing time as the timestamp.
Timestamp values should be in one of two formats:
- A numerical value representing the number of milliseconds since the
Unix epoch.
- A string in RFC 3339 format, UTC timezone. Example:
``2015-10-29T23:41:41.123Z``. The sub-second component of the
timestamp is optional, and digits beyond the first three (i.e., time
units smaller than milliseconds) may be ignored.
publish_time_field: Field to add to output messages with the Pub/Sub
message publish time. If None, no such field is added.
"""
if topic and subscription:
raise TypeError('Only one of topic and subscription may be specified.')
elif not topic and not subscription:
raise TypeError('One of topic or subscription may be specified.')
if publish_time_field is not None and not publish_time_field.strip():
raise ValueError('publish_time_field must be a non-empty field name.')
has_publish_time_field = publish_time_field is not None
payload_schema, parser = _create_parser(format, schema)
extra_fields: list[schema_pb2.Field] = []
if not attributes and not attributes_map and not has_publish_time_field:
mapper = lambda msg: parser(msg)
else:
if isinstance(attributes, str):
attributes = [attributes]
if attributes:
extra_fields.extend(
[schemas.schema_field(attr, str) for attr in attributes])
if attributes_map:
extra_fields.append(
schemas.schema_field(attributes_map, Mapping[str, str]))
if has_publish_time_field:
extra_fields.append(
schemas.schema_field(publish_time_field, Optional[Timestamp]))
View on GitHub (pinned to 12126d8942)