Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/EntitySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public function get(Transaction $transaction, ?ContextInterface $context = null)
}

$this->assertValidOrderBy();
$this->assertValidFilter();

return $transaction->getResponse()->setResourceCallback($this, function () use ($transaction, $context) {
$context = $context ?: $this;
Expand Down Expand Up @@ -1131,6 +1132,25 @@ protected function assertValidOrderBy(): void
}
}

/**
* Assert that the $filter expression is syntactically valid and references only known properties.
* This runs BEFORE the streaming response begins so that an invalid filter yields HTTP 400
* rather than a malformed mid-stream error fragment.
* @return void
*/
protected function assertValidFilter(): void
{
$filter = $this->getFilter();

if (!$filter->hasValue()) {
return;
}

$parser = $this->getFilterParser();
$parser->pushEntitySet($this);
$parser->generateTree($filter->getExpression());
}

/**
* Assert that the attached type has searchable properties
* @return void
Expand Down