Skip to content

docs(py): check res.error for provider failures in migration guide - #40

Merged
huangjeff5 merged 5 commits into
mainfrom
huangjeff/py-provider-error-check
Nov 11, 2026
Merged

huangjeff5 merged 5 commits into
mainfrom
huangjeff/py-provider-error-check

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

ai.generate() puts provider failures on res.error instead of raising them. The 0.12 migration guide and the Ollama README still said to catch GenkitError, and that handler never runs.

# --- BEFORE (what the docs said) ---
try:
    res = await ai.generate(model='ollama/llama3.2', prompt='Suggest a dish.')
except GenkitError as e:
    if e.status == 'UNAVAILABLE': ...   # never reached; generate returned instead

# --- AFTER ---
res = await ai.generate(model='ollama/llama3.2', prompt='Suggest a dish.')
if res.error and res.error.status == 'UNAVAILABLE':
    print(res.error.message)
    # => Cannot reach the Ollama server at http://127.0.0.1:11434. Start it with `ollama serve` (or set base_url to a reachable host).

Changes

  • Provider failures live on res.error: Once generate starts, it catches a plugin's GenkitError and returns it on the response with its status and message intact. The guide's "Plugin exception types" section now checks res.error.status instead of catching.
  • Embedders still raise: ai.embed doesn't catch, so an unreachable Ollama server still raises GenkitError(UNAVAILABLE) there. The Ollama troubleshooting note now says which call does which.
  • Unrelated docstring fix: enable_google_cloud_telemetry said the metric export interval defaults to 60000ms. The code uses 300000ms (DEFAULT_METRIC_EXPORT_INTERVAL_MS), or 5000ms when GENKIT_ENV=dev.

Breaking changes

None.

@huangjeff5
huangjeff5 force-pushed the huangjeff/py-provider-error-check branch from 342a61f to bd652a8 Compare November 9, 2026 19:07
@huangjeff5 huangjeff5 changed the title docs(py): check res.error for provider failures in the 0.12 migration guide docs(py): check res.error for provider failures in migration guide Nov 10, 2026
@huangjeff5
huangjeff5 requested a review from hilariie November 10, 2026 05:12
cabljac
cabljac previously approved these changes Nov 10, 2026

@cabljac cabljac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comments

Comment thread docs/migrating-from-0.12.md Resolved
cabljac
cabljac previously approved these changes Nov 10, 2026

@cabljac cabljac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comments

Comment thread docs/migrating-from-0.12.md Resolved
huangjeff5 and others added 5 commits November 11, 2026 00:09
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
…y/_tracing.py

Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
@huangjeff5
huangjeff5 force-pushed the huangjeff/py-provider-error-check branch from 8728ad6 to 6ba23fc Compare November 11, 2026 06:23
@huangjeff5
huangjeff5 merged commit 4157246 into main Nov 11, 2026
21 checks passed
@huangjeff5
huangjeff5 deleted the huangjeff/py-provider-error-check branch November 11, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants