Hi folks :wave:, I tried to ask Marvin but it did ...
# ask-community
g
Hi folks šŸ‘‹, I tried to ask Marvin but it did not help in my case, so I will try to ask my question here. šŸ‘‰ I am running the following command
Copy code
prefect deployment build path-to-file/prefect_flows.py:simple_test --name simple_test_flow -sb github/my-cicd -t some_tags --apply
and I have an existing block on prefect cloud that can be easily accessed as follows
Copy code
from prefect_github.repository import GitHubRepository

github_repository_block = GitHubRepository.load("my-cicd")
Why am i getting the following error:
ValueError: Unable to find block document named my-cicd for block type github
? Currently using the Prefect version: 2.19.7 - thanks šŸ’”
n
hi @GiuxJua - this usually happens when you're mistakenly pointing at a workspace (or local ephemeral API) that doesnt have your block registered what does
prefect config view
show?
g
Hey @Nate thanks for the reply - it seems weird to me, since all the config (and secrets) point exactly to the right ones šŸ˜ž and the block is living in the right project. However, I found an interesting issue: • if we use the "old" github block class (that is gonna live until Sept 2024) then the flow is deployed and run successfully šŸŽ‰ • if we use the "new" github blocks then the error is raised. Any idea of where this is happening? Where should I rise this issue so that possiblyother people can be aware of?
n
when you used the "new" GitHub block, did you use the one from
prefect-github
? had you created a block named
my-cicd
of that type?
g
Hey @Nate yes - the new refers to the
prefect-github
library. If, instead, I use the deprecated way, everything works - it seems to me a bug.
n
can you show the entire stack trace?
g
@Nate here it is (ENV is just a fancy name to avoid sensitive info to be public)
Copy code
Traceback (most recent call last):
  File "/home/runner/.cache/virtualenvs/ENV/lib/python3.11/site-packages/prefect/blocks/core.py", line 743, in _get_block_document
    block_document = await client.read_block_document_by_name(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/client/orchestration.py", line 1505, in read_block_document_by_name
    raise prefect.exceptions.ObjectNotFound(http_exc=e) from e
prefect.exceptions.ObjectNotFound


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



Traceback (most recent call last):

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/cli/_utilities.py", line 41, in wrapper

    return fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 259, in coroutine_wrapper

    return call()

           ^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 432, in __call__

    return self.result()

           ^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 318, in result

    return self.future.result(timeout=timeout)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 179, in result

    return self.__get_result()

           ^^^^^^^^^^^^^^^^^^^

  File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result

    raise self._exception

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 389, in _run_async

    result = await coro

             ^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/cli/deployment.py", line 1555, in build

    storage = await Block.load(storage_block)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/client/utilities.py", line 78, in with_injected_client

    return await fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/blocks/core.py", line 838, in load

    block_document, block_document_name = await cls._get_block_document(name)

                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/client/utilities.py", line 78, in with_injected_client

    return await fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/runner/.cache/pypoetry/virtualenvs/ENV/lib/python3.11/site-packages/prefect/blocks/core.py", line 747, in _get_block_document

    raise ValueError(

ValueError: Unable to find block document named my-cicd for block type github

An exception occurred.
The strange thing is that
Copy code
from prefect_github.repository import GitHubRepository

github_repository_block = GitHubRepository.load("my-cicd")
works from a python shell. However, under the deployment it raises this issue (which is then solved using the old way, i.e.
from prefect.filesystems import GitHub
n
hmm so if you do
prefect block ls | grep github-repository
you do have an entry for that specific block type? this > ValueError: Unable to find block document named my-cicd for block type github doesnt make sense to me if that is the case
g
Hey @Nate thanks for the reply - running your code gives me
sha_code │ GitHub Repository  │ my-cicd             │ github-repository/my-cicd
so the block exists, and lives in the right project. I therefore cannot understand why that is not working. The strange thing is that using the
prefect.flesysyem.GitHub
class works and this is something I cannot understand why. Any chance for a follow up? šŸ™
Just for clarity, recall this issue is raised when i try to deploy a flow with
Copy code
prefect deployment build ./$FILE_PATH:$FLOW_NAME \
  --name $FLOW_DEPLOYMENT_NAME \
  -sb $MY_CICD \
  -t $FLOW_TAG \
  --apply
and the error is shown by the github actions workflow. The deployment goes successfull when using the "old" GitHub Block. Thanks again
n
>
ValueError: Unable to find block document named my-cicd for block type github
hmm i bet you're right and this is a bug around the block type slug. because
github
should correspond to
prefect.filesystem.Github
, not
prefect_github.repository.GitHubRepository
can you please share the output of the following so I can look into this?
Copy code
pip list | grep -E 'prefect|github'