Jason Wiener
10/24/2025, 6:22 PMMarvin
10/24/2025, 6:22 PMMarvin
10/24/2025, 6:29 PMGitHubCredentials.load("name") in a flow, Prefect loads the stored data from the API but instantiates it with the class from your local environment. If dev has a newer/older prefect-github, you’ll see different properties/methods (e.g., a method being renamed or a field changed).
- Schema drift: Minor changes like access_token vs token or method name changes can cause AttributeError/ValidationError differences across environments.
How to confirm
1) Check your current workspace
prefect cloud workspace ls
prefect cloud workspace set
2) Compare installed versions in prod vs dev
- In each runtime/venv:
pip show prefect prefect-github
(or print them from Python)
3) Compare block types and schemas in each workspace
prefect blocks type ls
prefect blocks type inspect github-credentials
4) Inspect the specific block document(s)
prefect blocks inspect github-credentials/<your-block-name>
How to align prod and dev
- Standardize package versions in both environments:
pip install "prefect==3.4.20" "prefect-github==<your-target-version>"
- Re-register the block types in each workspace from the environment with your target version. This updates the workspace’s block type schema to match the code you have installed:
prefect block register -m prefect_github
# or, more narrowly
prefect block register -m prefect_github.credentials
- If you must load an older document with a newer class temporarily, you can bypass strict validation and then update/resave the block:
from prefect_github import GitHubCredentials
creds = GitHubCredentials.load("my-github-creds", validate=False)
# update fields if needed, then creds.save(name="my-github-creds")
Next steps
- If you can share:
- The exact error messages (especially the missing attribute/property)
- The output of pip show prefect-github in prod vs dev
- The output of prefect blocks type inspect github-credentials from each workspace
…we can pinpoint whether you’re hitting a method rename or a field change and suggest the minimal change (either re-registering or code updates).
References
- Blocks concepts (Prefect 3.x)
- CLI: block commands
- prefect-github integrationJason Wiener
10/24/2025, 6:42 PMGitHub Credentials
┌──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Slug │ github-credentials │
│ Block Type id │ ce8bbe1c-11e6-4bd9-b455-b44efc1f82f6 │
│ Description │ Block used to manage GitHub authentication │
└──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Schema Properties
┌────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ token │ description: A GitHub personal access token (PAT). │
│ │ format: password │
│ │ title: Token │
│ │ type: string │
│ │ writeOnly: true │
│ │ │
└────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
In prod, the schema is different:
GitHub Credentials
┌──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Slug │ github-credentials │
│ Block Type id │ c7c17b13-9609-4626-b985-c5d14a6f4949 │
│ Description │ Block used to manage GitHub authentication │
└──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Schema Properties
┌────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ token │ anyOf: │
│ │ - format: password │
│ │ type: string │
│ │ writeOnly: true │
│ │ - type: 'null' │
│ │ default: null │
│ │ description: A GitHub personal access token (PAT). │
│ │ title: Token │
│ │ │
└────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
In prod, there is an existing github-credentials block that is part of the pull configuration for deployment code. It is important to not disturb this when getting the new block working.Marvin
10/24/2025, 6:44 PMMarvin
10/24/2025, 6:45 PMgithub-credentials) across your dev and prod workspaces. In dev, token is required; in prod, token is optional (anyOf: string|null with a default of null). The different Block Type IDs confirm they’re distinct schemas that were registered at different times/with different prefect-github versions.
Key implications
- Workspace-local registration: Each Prefect Cloud workspace has its own registry. Registering or updating a block type in prod would change the prod schema for everyone in that workspace. Since you have a prod deployment that relies on a GitHub Credentials block for pull, you’re right to avoid disturbing it.
- Runtime code matters: When you load a block in your flow, Prefect deserializes the stored data but instantiates it with whatever version of prefect-github is installed in that runtime. If methods/properties differ between versions, you’ll see different behaviors/errors even when loading the same block document.
Safest path to get a new block working in prod without disturbing the existing one
- Do NOT re-register block types in prod right now.
- Create a new GitHub Credentials block document in prod under a new name and include a non-empty token value (even though the prod schema allows null).
- Prefect Cloud UI: Blocks > GitHub Credentials > Create, give it a unique name (e.g., github-creds-new) and set the PAT.
- This will not touch the existing prod credentials block used by your deployment pull config.
- In your flow code, load the new block and guard against schema differences:
from prefect_github import GitHubCredentials
creds = GitHubCredentials.load("github-creds-new", validate=False)
# Ensure token is present; schema in prod allows null by default
token_val = getattr(creds, "token", None)
if not token_val:
raise RuntimeError("GitHubCredentials token is missing in the prod block.")
# If the field is a SecretStr, get the raw value
if hasattr(token_val, "get_secret_value"):
token_val = token_val.get_secret_value()
# Use creds as intended by your version of prefect-github from here
# (e.g., pass creds into your from_source/deploy logic or client creation)
- If you’re seeing attribute/method errors that imply the block’s API changed between versions, make your usage resilient:
# Example pattern; method names can differ by version
# Prefer hasattr checks instead of assuming a specific method exists
if hasattr(creds, "get_client"):
gh = creds.get_client()
elif hasattr(creds, "get_github_client"):
gh = creds.get_github_client()
else:
# As a last resort, build your own client using the token_val
# e.g., PyGithub: Github(token_val)
raise RuntimeError("No known client creation method on GitHubCredentials.")
I’m not asserting exact method names here because they can change by version; the point is to guard with hasattr to avoid breaking prod while you align environments.
How to confirm and compare environments
- Check your current workspace to ensure you’re looking at prod vs dev:
prefect cloud workspace ls
prefect cloud workspace set
- Inspect block type and block documents:
prefect blocks type ls
prefect blocks type inspect github-credentials
prefect blocks inspect github-credentials/<block-name>
- Compare installed versions in your dev and prod runtimes:
pip show prefect prefect-github
Longer-term options (when you’re ready)
- Standardize versions: Pin the same prefect and prefect-github versions in dev and prod runtimes. If you need different versions for different workloads, run them in separate worker images/work pools so you don’t impact the deployment that performs code pulls.
- If/when you want schemas unified in prod, plan a maintenance window and re-register the block type from your chosen image:
```
prefect block register -m prefect_github
# or specificallyMarvin
10/24/2025, 6:45 PM