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

/connect_waves: HTTPExceptionをreturnではなくraiseするように修正 #763

Merged

Conversation

aoirint
Copy link
Member

@aoirint aoirint commented Oct 9, 2023

内容

ConnectBase64WavesExceptionが発生した場合にHTTPExceptionreturnされてしまっていたので、raiseするように修正します。

HTTPExceptionreturnされた場合、例外オブジェクトをFileResponseとして返そうとしてHTTP 500になります(末尾参照)。

Because it's a Python exception, you don't return it, you raise it.

関連 Issue

スクリーンショット・動画など

その他

/connect_wavesConnectBase64WavesExceptionがキャッチされた場合のレスポンス

関数の先頭で疑似的にHTTPExceptionをreturnしたときのエラー出力

INFO:     ***:*** - "POST /connect_waves HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "***\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 373, in run_asgi
    result = await app(self.scope, self.receive, self.send)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\site-packages\fastapi\applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "***\Lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "***\Lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
    raise exc
  File "***\Lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "***\Lib\site-packages\starlette\middleware\base.py", line 53, in __call__
    async with anyio.create_task_group() as task_group:
  File "***\Lib\site-packages\anyio\_backends\_asyncio.py", line 597, in __aexit__
    raise exceptions[0]
  File "***\Lib\site-packages\starlette\middleware\base.py", line 30, in coro
    await self.app(scope, request.receive, send_stream.send)
  File "***\Lib\site-packages\starlette\middleware\cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "***\Lib\site-packages\starlette\middleware\cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "***\Lib\site-packages\starlette\exceptions.py", line 82, in __call__
    raise exc
  File "***\Lib\site-packages\starlette\exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "***\Lib\site-packages\starlette\routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "***\Lib\site-packages\starlette\routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "***\Lib\site-packages\starlette\routing.py", line 61, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "***\Lib\site-packages\fastapi\routing.py", line 250, in app
    response = actual_response_class(response_data, **response_args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\site-packages\starlette\responses.py", line 252, in __init__
    media_type = guess_type(filename or path)[0] or "text/plain"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\site-packages\starlette\responses.py", line 30, in guess_type
    return mimetypes_guess_type(url, strict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\mimetypes.py", line 307, in guess_type
    return _db.guess_type(url, strict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Lib\mimetypes.py", line 122, in guess_type
    url = os.fspath(url)
          ^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not dict

@aoirint aoirint requested a review from a team as a code owner October 9, 2023 09:19
@aoirint aoirint requested review from y-chan and removed request for a team October 9, 2023 09:19
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

Coverage Result

Resultを開く
Name Stmts Miss Cover
run.py 446 298 coverage-33%
voicevox_engine/init.py 1 0 coverage-100%
voicevox_engine/acoustic_feature_extractor.py 75 0 coverage-100%
voicevox_engine/cancellable_engine.py 85 66 coverage-22%
voicevox_engine/dev/core/init.py 2 0 coverage-100%
voicevox_engine/dev/core/mock.py 27 12 coverage-56%
voicevox_engine/dev/synthesis_engine/init.py 2 0 coverage-100%
voicevox_engine/dev/synthesis_engine/mock.py 36 2 coverage-94%
voicevox_engine/downloadable_library.py 93 5 coverage-95%
voicevox_engine/engine_manifest/EngineManifest.py 34 0 coverage-100%
voicevox_engine/engine_manifest/EngineManifestLoader.py 12 0 coverage-100%
voicevox_engine/engine_manifest/init.py 3 0 coverage-100%
voicevox_engine/full_context_label.py 162 3 coverage-98%
voicevox_engine/kana_parser.py 86 1 coverage-99%
voicevox_engine/metas/Metas.py 33 0 coverage-100%
voicevox_engine/metas/MetasStore.py 29 12 coverage-59%
voicevox_engine/metas/init.py 2 0 coverage-100%
voicevox_engine/model.py 160 9 coverage-94%
voicevox_engine/mora_list.py 4 0 coverage-100%
voicevox_engine/morphing.py 70 46 coverage-34%
voicevox_engine/part_of_speech_data.py 5 0 coverage-100%
voicevox_engine/preset/Preset.py 12 0 coverage-100%
voicevox_engine/preset/PresetError.py 2 0 coverage-100%
voicevox_engine/preset/PresetManager.py 81 2 coverage-98%
voicevox_engine/preset/init.py 4 0 coverage-100%
voicevox_engine/setting/Setting.py 11 0 coverage-100%
voicevox_engine/setting/SettingLoader.py 19 0 coverage-100%
voicevox_engine/setting/init.py 3 0 coverage-100%
voicevox_engine/synthesis_engine/init.py 5 0 coverage-100%
voicevox_engine/synthesis_engine/core_wrapper.py 201 146 coverage-27%
voicevox_engine/synthesis_engine/make_synthesis_engines.py 59 30 coverage-49%
voicevox_engine/synthesis_engine/synthesis_engine.py 130 11 coverage-92%
voicevox_engine/synthesis_engine/synthesis_engine_base.py 67 9 coverage-87%
voicevox_engine/user_dict.py 144 11 coverage-92%
voicevox_engine/utility/init.py 5 0 coverage-100%
voicevox_engine/utility/connect_base64_waves.py 37 0 coverage-100%
voicevox_engine/utility/core_version_utility.py 8 1 coverage-88%
voicevox_engine/utility/mutex_utility.py 10 0 coverage-100%
voicevox_engine/utility/path_utility.py 26 8 coverage-69%
TOTAL 2191 672 coverage-69%

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

全く気づきませんでした。
型がしっかりしていれば気づけた問題かもしれませんね・・・ 😇

@Hiroshiba Hiroshiba merged commit 6506af4 into VOICEVOX:master Oct 9, 2023
3 checks passed
@aoirint aoirint deleted the patch-fix_connect_waves_raise_error branch October 9, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants