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

オープン 初心者向け
#7,516 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
openapi, python

調査の方向性

batch_prediction_broken_site_report の docstring を見つけます。これは POST /<model_name>/predict/broken_site_report/batch を文書化しています。まず properties: の下にある reports: とその子要素のインデントを修正します。次に /swagger を呼び出して仕様が読み込まれることを確認します。そのエンドポイントのテストを追加すれば、同様のミスを見つけやすくなります。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
579
フォーク
369
平均マージ
3日 5時間
マージ済み PR(30日)
139

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mozilla/bugbug のほかの issue

mozilla/bugbug の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。