http service: /swagger returns 500 because of a mis-indented requestBody schema in the broken site report batch endpoint

Đang mở Phù hợp với người mới
#7,516 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
openapi, python
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Tìm docstring của batch_prediction_broken_site_report, tài liệu hóa POST /<model_name>/predict/broken_site_report/batch. Bắt đầu bằng cách sửa thụt lề của reports: và các phần tử con bên dưới properties:. Sau đó gọi /swagger để xác nhận đặc tả được tải; thêm một bài kiểm thử cho endpoint đó sẽ giúp phát hiện các lỗi tương tự.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The /swagger endpoint of the http service fails with a 500:

  File ".../apispec/ext/marshmallow/schema_resolver.py", line 290, in resolve_schema_dict
    for k, v in schema["properties"].items()
AttributeError: 'NoneType' object has no attribute 'items'

The spec is generated from the docstrings of all routes, and the failing one is batch_prediction_broken_site_report (POST /<model_name>/predict/broken_site_report/batch). In its requestBody schema, reports: is at the same indentation level as properties: instead of being nested under it:

schema:
  type: object
  properties:
  reports:
    type: array
    ...

so properties is parsed as null. It dates back to bb54c090 (#3846). Since a single bad route makes the whole spec fail, /swagger (and the /doc page using it) are broken for every endpoint.

Fix: indent reports: (and its children) under properties:. A test calling /swagger would catch similar docstring mistakes in the future.

Ngôn ngữ chính
Python
Star
579
Fork
369
Merge trung bình
3 ngày 5 giờ
Pull request đã merge (30 ngày)
139

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mozilla/bugbug

Tất cả issue của mozilla/bugbug

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.