Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5815] Truncate search queries that are too long #5914

Merged

Conversation

garethrees
Copy link
Member

The maximum length of a search query is 252 bytes. People often paste
long strings into the typeahead search which results in an exception
being raised.

Instead of raising an exception, just truncate the query.

We could tell the user the string is too long, but I don't think it's
worth it in this case. The typeahead search is pretty opaque to users –
it just happens as they enter content – and with a string that long I
don't think we'll lose much by truncating it.

Fixes #5815.

Copy link
Member

@gbp gbp left a comment

Choose a reason for hiding this comment

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

Nice, never used mb_chars before

@gbp gbp assigned garethrees and unassigned gbp Oct 12, 2020
@garethrees
Copy link
Member Author

Nice, never used mb_chars before

Yeah it's nice for this kind of thing. I think I first learned of it via 5dcbded

The maximum length of a search query is 252 bytes. People often paste
long strings into the typeahead search which results in an exception
being raised.

Instead of raising an exception, just truncate the query.

We could tell the user the string is too long, but I don't think it's
worth it in this case. The typeahead search is pretty opaque to users –
it just happens as they enter content – and with a string that long I
don't think we'll lose much by truncating it.

Fixes #5815.
@mysociety-pusher mysociety-pusher force-pushed the 5815-truncate-too-long-typahead-search-query branch from 059a3a0 to 0cf2086 Compare October 14, 2020 12:47
@mysociety-pusher mysociety-pusher merged commit 3ced046 into develop Oct 14, 2020
@mysociety-pusher mysociety-pusher deleted the 5815-truncate-too-long-typahead-search-query branch October 14, 2020 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ERROR] request search_typeahead (ArgumentError) "InvalidArgumentError: Key too long…"
3 participants