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

@extend_schema_view warnings do not result in failure with --fail-on-warn #706

Closed
glennmatthews opened this issue Apr 13, 2022 · 2 comments
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@glennmatthews
Copy link
Contributor

Describe the bug

Warnings emitted by https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/utils.py#L560 do not result in failure when spectacular is run with --fail-on-warn:

# nautobot-server spectacular --fail-on-warn --file /dev/null
Warning #0: @extend_schema_view argument "bulk_update" was not found on view IPAddressViewSet. method override for "bulk_update" will be ignored.
Warning #1: @extend_schema_view argument "bulk_partial_update" was not found on view IPAddressViewSet. method override for "bulk_partial_update" will be ignored.
# echo $?
0

Possibly a similar root cause to #702?

To Reproduce
Use @extend_schema_view with a non-standard method name, such as:

@extend_schema_view(
    bulk_update=extend_schema(responses={"200": serializers.IPAddressSerializerLegacy(many=True)}, versions=["1.2"]),
    ...
)
class IPAddressViewSet(...)

(Note that in our specific case the warning is a bit spurious, see nautobot/nautobot#1637 for how we are resolving the warning.)

Expected behavior
When run with --fail-on-warn, any warning reported should cause a failure.

@tfranzel
Copy link
Owner

hey @glennmatthews, good catch! Took a moment to grasp the issue. The issue is that we have in total 2 warnings that are emitted during decoration time. You found one! Everything else is emitted during schema generation time. Since we clear the warning/error cache prior to generation, the message shows up in the console but is subsequently lost. Since its cleared there is no reason to raise anymore.

I'll try to figure out how to save those warnings. #702 is exactly the same issue provoked through another code path (check)

@tfranzel tfranzel added the bug Something isn't working label Apr 18, 2022
@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Apr 20, 2022
@tfranzel
Copy link
Owner

closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants