Skip to content

Don't error on non existing version #6325

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

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Oct 23, 2019

if not kwargs['filters']['version']:
raise ValidationError("Unable to find a version to search")
log.info("Unable to find a version to search")
return HTMLFile.objects.none()
Copy link
Member

Choose a reason for hiding this comment

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

Some lines below, we are returning a PageSearch object. Shouldn't we return something similar here instead of a different queryset object?

Copy link
Member Author

Choose a reason for hiding this comment

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

PageSearch isn't an django model, is an elastic search document based on HTMLFile. Actually it's weird becuase the PagaSearch has an interface similar to what django rest framework expects (there is a comment for that in this class or somewhere else). Also, funny that returning an empty PageSearch doesn't work with django rest framework.

From what I saw, we can return real HTMLFile objects, but that requires a query to the db, so I guess that's why we are not doing that and doing this hacky thing.

Copy link
Member

Choose a reason for hiding this comment

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

There's also an open issue related to this: #5235

@stsewd stsewd force-pushed the dont-error-on-wrong-input branch from 68de6a6 to 4817473 Compare October 28, 2019 18:52
@humitos humitos requested a review from dojutsu-user October 30, 2019 14:05
Copy link
Member

@dojutsu-user dojutsu-user left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@ericholscher ericholscher merged commit f30eb28 into readthedocs:master Nov 6, 2019
@stsewd stsewd deleted the dont-error-on-wrong-input branch November 6, 2019 16:00
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.

4 participants