Flask plugin does not gracefully fail when view is None

オープン
#133 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@Fire162 がすでに取り組んでいます。

2026年10月26日 から。

  • #227 @Fire162 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
flask, python
領域
api, backend

調査の方向性

flask.py の path_helper から始め、view=None の動作を core.py に示されている PluginMethodNotImplementedError の処理と比較してください。複数のプラグインによる path-helper のフローを検証し、view が存在しない場合でも assertion を発生させずに後続のプラグインが実行されることを確認してください。view がない場合に Flask プラグインがそのフローをブロックしなくなれば完了です。

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

説明

I cannot use spec.path without providing view.

In flask.py:

def path_helper(
        self,
        path: Optional[str] = None,
        operations: Optional[dict] = None,
        parameters: Optional[List[dict]] = None,
        *,
        view: Optional[Union[Callable[..., Any], "RouteCallable"]] = None,
        app: Optional[Flask] = None,
        **kwargs: Any,
    ) -> Optional[str]:
        """Path helper that allows passing a Flask view function."""
        assert view is not None

The assert statement completely fails, this means that if someone was to define multiple plugins for apispec, then because this one fails any time view is not defined, there is no way forward.

Inside core.py inside the apispec, library, they handle any PluginMethodNotImplementedErrors, and move on. I would suggest raising that exception instead.

for plugin in self.plugins:
            try:
                ret = plugin.path_helper(
                    path=path, operations=operations, parameters=parameters, **kwargs
                )
            except PluginMethodNotImplementedError:
                continue
主要言語
Python
スター
33
フォーク
25
平均マージ
6時間 59分
マージ済み PR(30日)
7

環境構築

はじめの一歩

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

marshmallow-code/apispec-webframeworks のほかの issue

marshmallow-code/apispec-webframeworks の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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