File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
src/fastapi_cloud_cli/commands Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -164,11 +164,17 @@ def _process_log_stream(
164164 toolkit .print (
165165 "The specified token is not valid. Use [blue]`fastapi login`[/] to generate a new token." ,
166166 )
167+ if isinstance (e , HTTPStatusError ) and e .response .status_code == 404 :
168+ toolkit .print (
169+ "App not found. Make sure to use the correct account." ,
170+ )
167171 elif isinstance (e , ReadTimeout ):
168172 toolkit .print (
169173 "The request timed out. Please try again later." ,
170174 )
171175 else :
176+ logger .exception ("Failed to fetch logs" )
177+
172178 toolkit .print (
173179 "Failed to fetch logs. Please try again later." ,
174180 )
Original file line number Diff line number Diff line change @@ -169,6 +169,21 @@ def test_handles_401_unauthorized(
169169 assert "token is not valid" in result .output
170170
171171
172+ @pytest .mark .respx (base_url = settings .base_api_url )
173+ def test_handles_404 (
174+ logged_in_cli : None , respx_mock : respx .MockRouter , configured_app : ConfiguredApp
175+ ) -> None :
176+ respx_mock .get (url__regex = rf"/apps/{ configured_app .app_id } /logs/stream.*" ).mock (
177+ return_value = httpx .Response (404 )
178+ )
179+
180+ with changing_dir (configured_app .path ):
181+ result = runner .invoke (app , ["logs" , "--no-follow" ])
182+
183+ assert result .exit_code == 1
184+ assert "App not found" in result .output
185+
186+
172187@pytest .mark .respx (base_url = settings .base_api_url )
173188def test_handles_500_server_error (
174189 logged_in_cli : None , respx_mock : respx .MockRouter , configured_app : ConfiguredApp
You can’t perform that action at this time.
0 commit comments