pathwaycom/pathway · error · ValueError
Received `direction` argument of join that is a string. You
Error message
Received `direction` argument of join that is a string. You probably want to use one of Direction.BACKWARD, Direction.FORWARD or Direction.NEAREST values.
What it means
After the string case is handled, the join kwargs handler verifies that 'direction' is actually an instance of pathway.stdlib.temporal.Direction. Any other non-string object (int, None, a custom constant) fails this check and raises this ValueError stating the required type. It is the catch-all branch that guarantees direction is exactly a Direction enum member.
Source
Thrown at python/pathway/internals/arg_handlers.py:136
if "defaults" in kwargs:
processed_kwargs["defaults"] = kwargs.pop("defaults")
if "left_instance" in kwargs and "right_instance" in kwargs:
processed_kwargs["left_instance"] = kwargs.pop("left_instance")
processed_kwargs["right_instance"] = kwargs.pop("right_instance")
elif "left_instance" in kwargs or "right_instance" in kwargs:
raise ValueError(
"`left_instance` and `right_instance` arguments to join "
+ "should always be provided simultaneously"
)
if "direction" in kwargs:
direction = processed_kwargs["direction"] = kwargs.pop("direction")
from pathway.stdlib.temporal import Direction
if isinstance(direction, str):
raise ValueError(
"Received `direction` argument of join that is a string.\n"
+ "You probably want to use one of "
+ "Direction.BACKWARD, Direction.FORWARD or Direction.NEAREST values."
)
if not isinstance(direction, Direction):
raise ValueError(
"direction argument of join should be of type asof_join.Direction."
)
if "behavior" in kwargs:
behavior = processed_kwargs["behavior"] = kwargs.pop("behavior")
from pathway.stdlib.temporal import CommonBehavior
if not isinstance(behavior, CommonBehavior):
raise ValueError(
"The behavior argument of join should be of type pathway.temporal.CommonBehavior."
)
View on GitHub (pinned to fa2f74a464)
Solutions
- Pass a Direction member: Direction.BACKWARD / Direction.FORWARD / Direction.NEAREST.
- Omit the kwarg entirely to take the default instead of passing None.
- Validate external direction inputs and map them to Direction members before the join.
Example fix
# before
direction = Direction # class, not member
pw.io.asof_join(left, right, left.time == right.time, direction=direction)
# after
pw.io.asof_join(
left, right, left.time == right.time, direction=Direction.NEAREST
) Defensive patterns
Strategy: type-guard
Validate before calling
from pathway.stdlib.temporal import Direction
if direction is not None:
assert isinstance(direction, Direction), (
f"direction must be a Direction member, got {type(direction).__name__}"
)
kwargs = {"direction": direction} if direction is not None else {} Type guard
from pathway.stdlib.temporal import Direction
def is_direction_member(v) -> bool:
return isinstance(v, Direction) Prevention
- Pass Direction members, not the Direction class or numeric codes.
- Omit the direction kwarg (rather than None) to use the default.
- Validate external direction inputs before asof joins.
When it happens
Trigger: direction=0 or direction=None passed explicitly; direction=Direction (the class itself instead of a member); custom sentinel objects intended as directions.
Common situations: Numeric direction codes from another system; defaulting direction to None meaning 'unspecified' instead of omitting the kwarg; passing the enum class rather than a member by forgetting the attribute access.
Related errors
- `left_instance` and `right_instance` arguments to join shoul
- direction argument of join should be of type asof_join.Direc
- Received `how` argument of join that is a string. You probab
- How argument of join should be one of JoinMode.INNER, JoinMo
- Received `id` argument of join that is a string. Did you mea
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/3a66aa58a09f44b9.
Report an issue: GitHub.