-
Notifications
You must be signed in to change notification settings - Fork 373
Bug 1928549: Fix API schema generation and 500 error on docs page #9148
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
base: master
Are you sure you want to change the base?
Conversation
|
@bhearsum Please can you review this if you get some time |
|
I'm not actually a reviewer for Treeherder.... @Archaeopteryx ? |
|
No problem. Thanks @bhearsum |
|
|
||
|
|
||
| class PerfomanceJobViewSet(viewsets.ReadOnlyModelViewSet): | ||
| class PerformanceJobViewSet(viewsets.ViewSet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing these typos while you were here :)
|
Hi @moijes12, thanks for looking into this! I see that there was a patch for django-filter that should have added the So it seems odd that we still need a custom filter backend for it - would you know why? It makes me wonder if there's a better solution that could fix this issue for us. |
|
Thanks @gmierz for your feedback I did try with the latest django-filter (version 25.2) and it did seem odd to me that it still did not work. However, I will give it a second shot and get back. |
This fixes the 500 error preventing the API documentation from loading by doing the below: * Add `TreeherderFilterBackend` to implement missing `get_schema_operation_parameters` method in `DjangoFilterBackend`. * Update `DEFAULT_FILTER_BACKENDS` and `performance_data.py` viewsets to use the new custom backend. * Change `PerformanceJobViewSet` to inherit from ViewSet to avoid `serializer_class` assertion errors. * Fix `AttributeError` in `PerfCompareResults.get_serializer_class` when request is `None` during schema generation. * Rename typos in DetailsPanel.jsx and PerformanceJobViewSet for consistency. Fixes Bug 1998273
…page" This reverts commit a3343f5.
django-filter recommends using drf_spectacular for generating OpenAPI schemas with DRF. See https://github.com/carltongibson/django-filter/blob/main/CHANGES.rst This change adds drf_spectacular for schema generation in settings. Also, the views have been updated to use the SpectacularAPIView.
Fixed the typo in the name of PerformanceData
|
I was able to fix the issue. As part of my latest change, I have:
|
This PR resolves a 500 error encountered when accessing the
/docs/and/api/schema/endpoints. The issue was caused by incompatibilities betweendjango-filteranddjangorestframework's schema generation, as well as missing attributes in specific API views.TreeherderFilterBackendto implement missingget_schema_operation_parametersmethod inDjangoFilterBackend.DEFAULT_FILTER_BACKENDSandperformance_data.pyviewsets to use the new custom backend.PerformanceJobViewSetto inherit from ViewSet to avoidserializer_classassertion errors.AttributeErrorinPerfCompareResults.get_serializer_classwhen request isNoneduring schema generation.@jmaher @gmierz
Fixes Bug 1928549