https://prefect.io logo
Title
d

Dominic Tarro

04/06/2023, 11:07 PM
Having trouble solving this bug. When I test the flow locally, it runs fine. But when I test it with an ECS Task, it throws this error.
Crash detected! Execution was interrupted by an unexpected exception: Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/client/orchestration.py", line 1031, in create_block_schema
    response = await <http://self._client.post|self._client.post>(
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 269, in send
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 132, in raise_for_status
    raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '409 Conflict' for url '<https://api.prefect.cloud/api/accounts/e5e970ea-d0a6-4ac5-992d-3796d5308920/workspaces/dbe8a5b3-2746-4ebd-8735-afdcc6550e47/block_schemas/>'
Response: {'detail': 'Data integrity conflict. This usually means a unique or foreign key constraint was violated. See server logs for details.'}
For more information check: <https://httpstatuses.com/409>

The above exception was the direct cause of the following exception:

ObjectAlreadyExists
def create_child_bucket(key: str, suffix: str, parent: S3Bucket) -> S3Bucket:
    """Creates a child bucket with a derived _block_document_name.

    :param key:         Child bucket's subpath
    :param suffix:      Suffix to append to the parent's document name.\
        Creates
    :param parent:    Bucket to create a child from, defaults to global\
        `bucket`
    :return:            Returns the child


    """
    child = create_bucket_with_resolved_subpath(key, parent)
    child = child.copy(
        # <https://github.com/PrefectHQ/prefect/blob/main/src/prefect/results.py>
        # Exclude the _block_document_id, this can be generated by the
        # ResultFactory and it will be saved anonymously there
        exclude={"_block_document_id"},
        update={
            "_block_document_name": parent._block_document_name + suffix,
            "_is_anonymous": True,
        },
    )
    return child
I have a task whose result_storage is an S3Bucket created by this function. It has worked fine elsewhere and I haven't had an issue with it in the past, but when I use the original bucket things work normally.
Crash detected! Execution was interrupted by an unexpected exception: Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/client/orchestration.py", line 1031, in create_block_schema
    response = await <http://self._client.post|self._client.post>(
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 269, in send
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 132, in raise_for_status
    raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '409 Conflict' for url '<https://api.prefect.cloud/api/accounts/e5e970ea-d0a6-4ac5-992d-3796d5308920/workspaces/dbe8a5b3-2746-4ebd-8735-afdcc6550e47/block_schemas/>'
Response: {'detail': 'Data integrity conflict. This usually means a unique or foreign key constraint was violated. See server logs for details.'}
For more information check: <https://httpstatuses.com/409>

The above exception was the direct cause of the following exception:

ObjectAlreadyExists
04:38:47 PM
prefect.flow_runs
Crash details:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/client/orchestration.py", line 1031, in create_block_schema
    response = await <http://self._client.post|self._client.post>(
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 269, in send
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/prefect/client/base.py", line 132, in raise_for_status
    raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '409 Conflict' for url '<https://api.prefect.cloud/api/accounts/e5e970ea-d0a6-4ac5-992d-3796d5308920/workspaces/dbe8a5b3-2746-4ebd-8735-afdcc6550e47/block_schemas/>'
Response: {'detail': 'Data integrity conflict. This usually means a unique or foreign key constraint was violated. See server logs for details.'}
For more information check: <https://httpstatuses.com/409>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 1692, in report_flow_run_crashes
    yield
  File "/usr/local/lib/python3.11/contextlib.py", line 716, in __aexit__
    cb_suppress = await cb(*exc_details)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 662, in __aexit__
    raise exceptions[0]
  File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 1209, in create_task_run_then_submit
    await submit_task_run(
  File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 1278, in submit_task_run
    result_factory=await ResultFactory.from_task(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/results.py", line 211, in from_task
    return await cls.from_settings(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/results.py", line 229, in from_settings
    storage_block_id, storage_block = await cls.resolve_storage_block(
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/results.py", line 257, in resolve_storage_block
    or await storage_block._save(
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/blocks/core.py", line 882, in _save
    await self.register_type_and_schema(client=client)
  File "/usr/local/lib/python3.11/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/blocks/core.py", line 841, in register_type_and_schema
    block_schema = await client.create_block_schema(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/client/orchestration.py", line 1041, in create_block_schema
    raise prefect.exceptions.ObjectAlreadyExists(http_exc=e) from e
prefect.exceptions.ObjectAlreadyExists
Extended crash details
n

Nathan Low

04/10/2023, 3:16 PM
Looks like a foreign key issue,
'detail': 'Data integrity conflict. This usually means a unique or foreign key constraint was violated. See server logs for details.'}
Are you inserting data into a different environment?