nautechsystems/nautilus_trader · error · anyhow::Error
Order side not set
Error message
Order side not set
What it means
OrderBuilder::build requires side to be explicitly set before constructing the proto Order; dYdX orders must declare BUY or SELL. The error is thrown when the builder's optional side field is still None.
Source
Thrown at crates/adapters/dydx/src/grpc/order.rs:420
self
}
/// Set order's expiration.
#[must_use]
pub fn until(mut self, gtof: OrderGoodUntil) -> Self {
self.until = Some(gtof);
self
}
/// Build the order.
///
/// # Errors
///
/// Returns an error if the order parameters are invalid.
pub fn build(self) -> Result<Order, anyhow::Error> {
let side = self
.side
.ok_or_else(|| anyhow::anyhow!("Order side not set"))?;
let size = self
.size
.ok_or_else(|| anyhow::anyhow!("Order size not set"))?;
// Quantize size
let quantums = self.market_params.quantize_quantity(size)?;
// Build order ID
let order_id = Some(OrderId {
subaccount_id: Some(SubaccountId {
owner: self.subaccount_owner.clone(),
number: self.subaccount_number,
}),
client_id: self.client_id,
order_flags: match self.flags {
OrderFlags::ShortTerm => 0,
OrderFlags::LongTerm => 64,
OrderFlags::Conditional => 32,View on GitHub (pinned to 18893faf8b)
Solutions
- Always call .side(...) on the builder before .build()
- Ensure the side-mapping from your internal order type to OrderSide cannot fall through to unset
- Add a validation check on the caller side before invoking build
Example fix
// before
let builder = OrderBuilder::new(params).size(size).until(until);
let order = builder.build()?;
// after
let builder = OrderBuilder::new(params)
.side(side) // must be set before build
.size(size)
.until(until);
let order = builder.build()?; Defensive patterns
Strategy: validation
Validate before calling
anyhow::ensure!(side.is_some(), "side must be set before build()");
Prevention
- Use a builder API that takes required fields in the constructor (side, size)
- Add unit tests for every order-type build path
- Centralize order construction so all required setters are always called
When it happens
Trigger: Calling build() (e.g. via build_conditional_order) without having called the builder's side setter, or a code path that conditionally sets side and skips it.
Common situations: Conditional order construction where side is derived from trigger logic and a branch forgets to set it; refactoring that renamed/moved the side() call; passing an OrderSide that failed to map and defaulted to None.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Order size not set
- Order expiration (until) not set
- slots lock poisoned
- AX whoami account {} supplied no fee rates
- DEX {} does not have initialize event set.
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/978be47fe3e8e782.
Report an issue: GitHub.