Server error '500 Internal Server Error' for url

I may have somehow broken my Prefect unknowingly and dont know how to fix it. Now even my most simplest flows show the same error.

When trying to revert I run this test.py

from prefect import flow
@flow
def my_favorite_function():
    print("What is your favorite number?")
    return 42

print(my_favorite_function())

The error is

(sandbox) ~/scratch$ python test.py 
13:42:44.133 | DEBUG   | prefect.client - Connecting to API at http://0.0.0.0:4200/api/
13:42:44.160 | INFO    | prefect.engine - Created flow run 'tomato-butterfly' for flow 'my-favorite-function'
13:42:44.160 | DEBUG   | Flow run 'tomato-butterfly' - Starting 'ConcurrentTaskRunner'; submitted tasks will be run concurrently...
13:42:44.161 | DEBUG   | prefect.task_runner.concurrent - Starting task runner...
13:42:44.166 | DEBUG   | prefect.client - Connecting to API at http://0.0.0.0:4200/api/
13:42:44.179 | DEBUG   | prefect.task_runner.concurrent - Shutting down task runner...
13:42:44.179 | ERROR   | Flow run 'tomato-butterfly' - Crash detected! Execution was interrupted by an unexpected exception: httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://0.0.0.0:4200/api/block_types/feb57929-1bca-4a1e-8cd8-2fd388628321'
For more information check: https://httpstatuses.com/500

13:42:44.180 | DEBUG   | Flow run 'tomato-butterfly' - Crash details:
Traceback (most recent call last):
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/engine.py", line 1574, in report_flow_run_crashes
    yield
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/engine.py", line 365, in begin_flow_run
    flow_run_context.result_factory = await ResultFactory.from_flow(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 161, in from_flow
    return await cls.default_factory(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 123, in default_factory
    return await cls.from_settings(**kwargs, client=client)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 229, in from_settings
    storage_block_id, storage_block = await cls.resolve_storage_block(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 257, in resolve_storage_block
    or await storage_block._save(is_anonymous=True, overwrite=True)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/blocks/core.py", line 759, in _save
    await self.register_type_and_schema(client=client)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/blocks/core.py", line 705, in register_type_and_schema
    await client.update_block_type(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/orion.py", line 1049, in update_block_type
    await self._client.patch(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_client.py", line 1922, in patch
    return await self.request(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/base.py", line 251, in send
    response.raise_for_status()
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_models.py", line 745, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://0.0.0.0:4200/api/block_types/feb57929-1bca-4a1e-8cd8-2fd388628321'
For more information check: https://httpstatuses.com/500
13:42:44.192 | DEBUG   | prefect.engine - Reported crashed flow run 'tomato-butterfly' successfully!
Traceback (most recent call last):
  File "/home/adam/Atmo/storage/Edwin/prefect-pipeline-scratch/scratch/test.py", line 8, in <module>
    print(my_favorite_function())
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/flows.py", line 448, in __call__
    return enter_flow_run_engine_from_flow_call(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/engine.py", line 164, in enter_flow_run_engine_from_flow_call
    return anyio.run(begin_run)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/anyio/_core/_eventloop.py", line 56, in run
    return asynclib.run(func, *args, **backend_options)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 233, in run
    return native_run(wrapper(), debug=debug)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 228, in wrapper
    return await func(*args)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/engine.py", line 237, in create_then_begin_flow_run
    state = await begin_flow_run(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/engine.py", line 365, in begin_flow_run
    flow_run_context.result_factory = await ResultFactory.from_flow(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 161, in from_flow
    return await cls.default_factory(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 123, in default_factory
    return await cls.from_settings(**kwargs, client=client)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 229, in from_settings
    storage_block_id, storage_block = await cls.resolve_storage_block(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/results.py", line 257, in resolve_storage_block
    or await storage_block._save(is_anonymous=True, overwrite=True)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/blocks/core.py", line 759, in _save
    await self.register_type_and_schema(client=client)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/blocks/core.py", line 705, in register_type_and_schema
    await client.update_block_type(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/orion.py", line 1049, in update_block_type
    await self._client.patch(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_client.py", line 1922, in patch
    return await self.request(
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/prefect/client/base.py", line 251, in send
    response.raise_for_status()
  File "/home/adam/anaconda3/envs/sandbox/lib/python3.10/site-packages/httpx/_models.py", line 745, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://0.0.0.0:4200/api/block_types/feb57929-1bca-4a1e-8cd8-2fd388628321'
For more information check: https://httpstatuses.com/500
13:42:44.199 | DEBUG   | prefect.client - Connecting to API at http://0.0.0.0:4200/api/

When I click on the ‘http://0.0.0.0:4200/api/block_types/feb57929-1bca-4a1e-8cd8-2fd388628321
For more information check: https://httpstatuses.com/500` link, I get this message

{"id":"feb57929-1bca-4a1e-8cd8-2fd388628321","created":"2022-12-22T01:32:39.651259+00:00","updated":"2022-12-23T01:22:44.848234+00:00","name":"Local File System","slug":"local-file-system","logo_url":"https://images.ctfassets.net/gm98wzqotmnx/EVKjxM7fNyi4NGUSkeTEE/95c958c5dd5a56c59ea5033e919c1a63/image1.png?h=250","documentation_url":null,"description":"Store data as a file on a local file system.","code_example":"Load stored local file system config:\n```python\nfrom prefect.filesystems import LocalFileSystem\n\nlocal_file_system_block = LocalFileSystem.load(\"BLOCK_NAME\")\n```","is_protected":true}

This was all running fine until I ran a script that tried to do some flows inside for loops and change the working directory too…

1 Like

It looks like the block got deleted

Usually local file system block is used under the hood so you shouldn’t have to use it directly. Did you create that block manually?

If you run all that locally and resetting the DB is feasible, you can reset the DB and restart Orion.

prefect orion database reset -y && prefect orion start