Skip to content

SRCH-694 return parser error for oversized days#84

Merged
xinganghuang merged 1 commit into
masterfrom
SRCH-694
Jun 25, 2026
Merged

SRCH-694 return parser error for oversized days#84
xinganghuang merged 1 commit into
masterfrom
SRCH-694

Conversation

@xinganghuang

@xinganghuang xinganghuang commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Fixes a parser crash when days() or weekdays() exceed the maximum allowed offset inside a multi-value expression (e.g. a Bt range).

Changes in ParserTools:

  • tokenize_function — After FunctionResolver#call, copy resolver errors into the parser when the call returns nil (errors added during call were previously ignored).
  • tokenize_multiple — Guard against nil operands so a failed function call does not cause NoMethodError on lit2[:type].
  • report_function_resolver_errors — New helper that forwards each ParserError from the resolver (token, message, status, syntax, constraint) instead of a generic error message.

Also adds a parser integration test and bumps the gem to v1.3.6.

Why

For filters like:

OpenHouses Bt days(0),days(9223372036854775807)

the second days() fails validation, tokenize_function returns nil, and tokenize_multiple then dereferences nil → NoMethodError → 500 in the API.

Expected behavior is a parser error (e.g. Function call 'days' max offset 365000 days), not an unhandled exception. This change ensures resolver validation failures are surfaced to the caller the same way as other parse errors.

AI

Cursor 3.8.11, Agent, Auto

@xinganghuang xinganghuang marked this pull request as ready for review June 23, 2026 21:34
Comment thread test/unit/parser_test.rb
assert_equal 0, expressions.last[:block_group]
end

test 'oversized days() in Bt range returns parser error instead of raising' do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ridley-james ridley-james left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@xinganghuang xinganghuang merged commit df0997d into master Jun 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants