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

Improve from search prefix error handling #37

Merged
merged 3 commits into from
Apr 9, 2022
Merged

Conversation

aescling
Copy link
Contributor

@aescling aescling commented Apr 5, 2022

addresses #36

note mastodon/mastodon#17963; i expect they will ask for adjustments there; i further expect to make impactful design changes. i am still opening this PR as we are currently running this on GlitchCat anyway, with no reported problems

)

* Improve robustness for account string validation

Using unsupported prefixes now reports a 422; searching for posts from an
account the instance is not aware of reports a 404. TODO: The UI for this
on the front end is abysmal.

Searching `from:username@domain` now succeeds when `domain` is the local
domain; searching `from:@username(@Domain)?` now works as expected.

* Satisfy upstream rubcocp

* Unbreak upstream tests
@aescling
Copy link
Contributor Author

aescling commented Apr 6, 2022

updated for upstream rubocop and upstream tests

@aescling
Copy link
Contributor Author

aescling commented Apr 8, 2022

we will not be incorporating upstream’s requested changes as i prefer to alert the user to syntactically invalid account strings; as well as to reject account strings like [email protected]@anthuesaho, which the upstream PR will accept

@aescling aescling changed the title Make from search prefix more robust (addresses mastodon/mastodon#17941) Improve from search prefix error handling (addresses mastodon/mastodon#17941) Apr 8, 2022
@aescling aescling changed the title Improve from search prefix error handling (addresses mastodon/mastodon#17941) Improve from search prefix error handling (addresses mastodon/mastodon#17941) #36 Apr 8, 2022
@aescling aescling changed the title Improve from search prefix error handling (addresses mastodon/mastodon#17941) #36 Improve from search prefix error handling Apr 8, 2022
app/controllers/api/v2/search_controller.rb Outdated Show resolved Hide resolved
app/lib/search_query_transformer.rb Outdated Show resolved Hide resolved
app/models/concerns/account_finder_concern.rb Outdated Show resolved Hide resolved
@marrus-sh
Copy link
Member

It’d be nice to have tests for at least the new methods, so that if something upstream breaks this we would have some manner of indication. I wouldn’t rate it as an especially high priority though.

We previously matched on one-character domains and domains ending with
`[\.-]`, allowing `from:@A@a` and `from:@A@a-` searches to cause an
account lookup. This commit will raise a syntax error in both cases, as
MENTION_RE would never match them.
Incorporates changes suggested in #37. In doing so, adopts an error
handling style more consistent with the existing codebase (for which I
must thank @ClearlyClaire).

Removes new code no longer in use.
@aescling
Copy link
Contributor Author

aescling commented Apr 9, 2022

i really should add tests but my smoke tests (running these commits briefly on GlitchCat and testing that searches work, and and that searchs 422 on one-character domain names or domain names ending not in :word:) raised no problems

(we really need to set up a test instance)

@aescling aescling requested a review from marrus-sh April 9, 2022 06:56
@aescling aescling linked an issue Apr 9, 2022 that may be closed by this pull request
@aescling aescling added STATUS: bug Improper behaviour LV.1: Application Backend @ installing and running the application labels Apr 9, 2022
Copy link
Member

@marrus-sh marrus-sh left a comment

Choose a reason for hiding this comment

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

LGTM. Feel free to merge if you don’t want to bother with tests yet; maybe at least run rubocop though if you haven’t since we don’t have CI.

@aescling
Copy link
Contributor Author

aescling commented Apr 9, 2022

rubocop reports no (new) offenses; i’m gonna merge and then immediately file an issue to write tests, since we really ought to

@aescling aescling merged commit b8e801a into main Apr 9, 2022
@aescling aescling deleted the more-robust-from-prefix branch April 9, 2022 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LV.1: Application Backend @ installing and running the application STATUS: bug Improper behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

from: search prefix 500s when the supplied account cannot be found
2 participants