Ricardo Ibarra
10/01/2025, 12:22 AMprefect-cloud deploy examples/hello.py:hello_world --from PrefectHQ/prefect-cloudMarvin
10/01/2025, 12:22 AMMarvin
10/01/2025, 12:34 AMprefect deploy (not prefect-cloud deploy), and there isn’t a `--from`/`--branch` flag. To deploy from a specific Git branch you have two good options:
Option A — Use prefect.yaml with a git pull step (works with the CLI)
1) Add a pull step that specifies the repo and branch:
name: my-project
deployments:
- name: hello
entrypoint: examples/hello.py:hello_world
pull:
- prefect.deployments.steps.git_clone:
repository: <https://github.com/PrefectHQ/prefect-cloud>
branch: my-branch
# credentials: '{{ prefect.blocks.github-credentials.my-creds }}' # if private
2) Run the deployment:
prefect deploy
Docs: prefect.yaml pull action
Option B — Use the Python API with from_source (fully remote, no local project)
from prefect import flow
from prefect.storage import GitRepository
# reference a specific branch
source = GitRepository(
url="<https://github.com/PrefectHQ/prefect-cloud>",
branch="my-branch",
)
deployment = flow.from_source(
source=source,
entrypoint="examples/hello.py:hello_world",
)
deployment.deploy(
name="hello",
work_pool_name="your-work-pool",
)
Docs: Store flow code and deploy from source
If you were hoping for a one-liner like --from PrefectHQ/prefect-cloud@my-branch, that isn’t supported in Prefect 3.x. The two patterns above are the supported ways to pin a branch.
Quick check: are you on Prefect 3.x and okay switching from prefect-cloud deploy to prefect deploy or using the Python approach? I can help tailor the exact snippet to your setup.Nate
10/01/2025, 1:02 AMprefect-cloud CLI, which is probably not documented as well as it should be (our bad)
@app.command(rich_help_panel="Deploy")
async def deploy(
function: Annotated[
str,
typer.Argument(
help="The path to the Python function to deploy in <path/to/file.py:function_name> format",
show_default=False,
),
],
repo: Annotated[
str,
typer.Option(
"--from",
"-f",
default_factory=infer_repo_url,
autocompletion=completions.complete_repo,
help=(
"GitHub repository reference in any of these formats:\n\n"
"• owner/repo\n\n"
"• owner/repo/tree/branch\n\n"
"• owner/repo/tree/commit-sha\n\n"
"If not provided, the repository of the current directory will be used."
),
rich_help_panel="Source",
show_default=False,
),
],Marvin
10/01/2025, 1:02 AMMarvin
10/01/2025, 1:02 AMprefect-cloud CLI.
To pin a branch with that CLI, use the /tree/<branch-name> form in the --from value. For your example:
prefect-cloud deploy examples/hello.py:hello_world --from PrefectHQ/prefect-cloud/tree/my-branch
A few notes:
- You can also pin a specific commit with /tree/<commit-sha>.
- Short flag works too: -f PrefectHQ/prefect-cloud/tree/my-branch.
- The examples/hello.py:hello_world path is resolved relative to the repo at that branch.
If you tell me the branch name you want, I can paste the exact command back.Ricardo Ibarra
10/01/2025, 7:35 PMTraceback (most recent call last):
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 127, in wrapper
return fn(*args, **kwargs)
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 165, in sync_fn
return run_sync(async_fn(*args, **kwargs))
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 308, in run_sync
return ctx.run(loop.run_until_complete, coro)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/deployments.py", line 271, in deploy
deployment_id = await client.create_managed_deployment(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<11 lines>...
)
^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/client.py", line 786, in create_managed_deployment
deployment_id = await self.create_deployment(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<8 lines>...
)
^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/client.py", line 348, in create_deployment
raise RequestError(f"Malformed response: {response}")
httpx.RequestError: Malformed response: <Response [403 Forbidden]>
An error occurred.Marvin
10/01/2025, 7:35 PMMarvin
10/01/2025, 7:38 PMprefect-cloud CLI tries to create a managed deployment. The branch syntax you used is fine; the error points to authorization or workspace/feature access, not the repo URL.
Most common causes for 403 here:
- You’re not logged in or your API key/workspace selection is stale
- Your role in the workspace doesn’t have permission to create deployments
- The quickstart “managed deployments” feature isn’t enabled for your account/workspace
Quick checks
1) Re-auth and re-target the workspace explicitly
prefect cloud login -k <YOUR_API_KEY> -w <account_handle>/<workspace_handle>
2) Confirm you’re on the intended profile
prefect profile ls
Look for the star next to the active profile that’s configured for your Cloud workspace.
3) Verify permissions in that workspace
You’ll need a role with deployment creation rights (e.g., Workspace Admin or a role with “Manage deployments”). If you’re on an account where the quickstart managed deployment feature isn’t enabled, this call will 403.
Then retry:
prefect-cloud deploy examples/hello.py:hello_world -f PrefectHQ/prefect-cloud/tree/my-branch
If the 403 persists
- Can you share:
- The exact command you ran (feel free to redact)
- Your account/workspace handle
- Your role in the workspace
- Whether you can create a deployment using the standard CLI in the same workspace
# prefect.yaml with git pull step
name: quick-test
deployments:
- name: hello
entrypoint: examples/hello.py:hello_world
pull:
- prefect.deployments.steps.git_clone:
repository: <https://github.com/PrefectHQ/prefect-cloud>
branch: my-branch
Then run:
prefect deploy
- For additional detail, you can turn on debug logging and re-run to capture more context:
PREFECT_LOGGING_LEVEL=DEBUG prefect-cloud deploy ...
Reference:
- prefect.yaml pull step docs: prefect.yaml pull action
If you prefer to bypass the quickstart CLI, the standard Prefect 3.x paths (prefect.yaml or Python flow.from_source with GitRepository(branch="...")) will let you pin a branch and create the deployment while we sort out the 403.Ricardo Ibarra
10/01/2025, 7:50 PMMarvin
10/01/2025, 7:50 PMMarvin
10/01/2025, 7:54 PMuvx prefect cloud login -k <YOUR_API_KEY> -w <account_handle>/<workspace_handle>
uvx prefect profile ls # confirm active profile (starred)
CLI help for reference:
uvx prefect cloud login --help
# Options:
# -k, --key TEXT API Key
# -w, --workspace TEXT '<account_handle>/<workspace_handle>'
Option 2: Override via environment variables on the deploy command
This bypasses whatever is saved in your profile.
PREFECT_API_KEY=<YOUR_API_KEY> \
PREFECT_API_URL=<https://api.prefect.cloud/api/accounts/<account_id>/workspaces/<workspace_id>> \
uvx prefect-cloud deploy examples/hello.py:hello_world -f PrefectHQ/prefect-cloud/tree/my-branch
Tip: You can copy the account_id/workspace_id from the Cloud UI URL bar (it contains /accounts/<id>/workspaces/<id>).
Option 3: Switch or clear your Prefect profile
- List profiles:
uvx prefect profile ls
- Switch to a different one (or after logging in above):
uvx prefect profile use <profile_name>
- As a last resort, remove the saved config:
- Close shells using Prefect, then delete ~/.prefect/profiles.toml (or remove the specific profile) and re-run Option 1.
Option 4: Use the quickstart CLI’s login with explicit workspace (if supported)
Run:
uvx prefect-cloud login --help
If there’s a --workspace or -w option, do:
uvx prefect-cloud logout
uvx prefect-cloud login -k <YOUR_API_KEY> -w <account_handle>/<workspace_handle>
Why this happens
- uvx isolates packages, not your Prefect profile. The active profile in ~/.prefect (or env vars) determines which Cloud account/workspace all Prefect tools (including prefect-cloud) hit.
If you share:
- the handle you want (account/workspace)
- whether you prefer login (Option 1/4) or env override (Option 2)
…I’ll paste back the exact command(s) for your case.Nate
10/01/2025, 7:54 PM--profile flagNate
10/01/2025, 7:55 PMprefect --profile local flow-run ls etcNate
10/01/2025, 7:55 PMlocal profileRicardo Ibarra
10/01/2025, 8:19 PMRicardo Ibarra
10/01/2025, 8:20 PMuvx prefect-cloud github setup I'm getting this error:
Traceback (most recent call last):
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 127, in wrapper
return fn(*args, **kwargs)
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 165, in sync_fn
return run_sync(async_fn(*args, **kwargs))
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/utilities.py", line 308, in run_sync
return ctx.run(loop.run_until_complete, coro)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/cli/github.py", line 25, in setup
await install_github_app_interactively(client)
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/github.py", line 282, in install_github_app_interactively
state_token = await client.get_github_state_token(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
redirect_url=cloud_callback_url
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/prefect_cloud/client.py", line 158, in get_github_state_token
response.raise_for_status()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/ricardoibarra/.cache/uv/archive-v0/BNRkMbhGcPkRBf7at926j/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '403 Forbidden' for url '<https://api.prefect.cloud/api/accounts/901b5d7c-926b-409d-bd3c-3bc95f8de244/integrations/github/state-token>'
For more information check: <https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403>Marvin
10/01/2025, 8:20 PMMarvin
10/01/2025, 8:22 PMuvx prefect cloud login -k <YOUR_API_KEY> -w <account_handle>/<workspace_handle>
uvx prefect config view | grep PREFECT_API_URL
uvx prefect profile ls
2) Check your role at the account level
- In the UI, go to the target account → Settings → Members and verify your role. You typically need Account Admin to manage account integrations like GitHub.
- If you don’t have admin, ask an Account Admin to run the setup or to grant you the role.
3) Try installing via the UI
- In the UI, go to the same account → Settings → Integrations → GitHub and click Install/Configure. This will initiate the GitHub App installation. You’ll need GitHub org admin rights to complete it if you’re installing into an org.
4) If your account doesn’t have the GitHub quickstart feature
- Reach out to your Prefect admin or support to enable the GitHub integration for your account. A 403 at that state-token endpoint can indicate the feature is not enabled for the account.
Workaround if you want to proceed without the quickstart GitHub integration
- You can still deploy from a Git branch using standard Prefect 3.x paths:
- prefect.yaml + git_clone pull step:
name: my-project
deployments:
- name: hello
entrypoint: examples/hello.py:hello_world
pull:
- prefect.deployments.steps.git_clone:
repository: <https://github.com/<owner>/<repo>>
branch: <branch>
# credentials: '{{ prefect.blocks.github-credentials.my-creds }}' # if private
Deploy:
uvx prefect deploy
- Or Python API with from_source:
from prefect import flow
from prefect.storage import GitRepository, GitCredentials
source = GitRepository(
url="<https://github.com/<owner>/<repo>.git>",
branch="<branch>",
# credentials=GitCredentials(token="<gh_pat>"), # if private
)
d = flow.from_source(source=source, entrypoint="examples/hello.py:hello_world")
d.deploy(name="hello", work_pool_name="your-work-pool")
If you can share:
- Your Prefect Cloud account role
- Whether you can see the GitHub integration under Settings → Integrations in the UI
- The account handle you’re targeting
…I can tailor the next step (UI path vs. enabling feature vs. CLI retry) and give you the exact commands or clicks to finish the setup.