Skip to content

Session error path drops cause and stack from ProviderInitError, hiding root cause #24430

Closed as not planned

Description

@NathanDrake2406

Description

When Provider.resolveSDK throws InitError({providerID}, {cause: e}) (packages/opencode/src/provider/provider.ts:1522), the session pipeline catches it and re-emits via new NamedError.Unknown({message: err.message}).toObject(). err.cause and stack are discarded.

Consumers (e.g. cli/cmd/github.ts:986) only see:

Agent error: { name: "UnknownError", data: { message: "ProviderInitError" } }

This makes CI failures undebuggable. The real failure (NPM install error, missing peer dep, network failure, etc.) lives on err.cause and is silently dropped.

Expected: preserve the original named error (name: "ProviderInitError") and pass cause chain through to the consumer, e.g.

new NamedError.Unknown({ message: err.message }, { cause: err.cause })

and serialize cause chain in toObject(). Or stop re-wrapping ProviderInitError as UnknownError at the session boundary.

OpenCode version

1.14.25 (also reproduces on 1.14.22)

Steps to reproduce

  1. Trigger any failure inside resolveSDK — easiest path: cloudflare-ai-gateway/openai/gpt-5.4 on a fresh CI runner (see loadOptions(dir) in Npm.add reify path fails on CI runners → silent ProviderInitError for dynamic providers #24431)
  2. Observe CI log shows only UnknownError: ProviderInitError — the underlying InstallFailedError and its cause are gone.

Operating System

Linux (GitHub Actions ubuntu-latest), macOS 25.4

Impact

Every cf-ai-gateway repo that hit the 1.14.x install regression saw an unactionable error. Multiple Cloudflare repos (workers-sdk, workerd, kumo, containers, vinext) pinned older opencode versions without an upstream issue because the symptom was not diagnosable.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 26, 2026
  2. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to existing issues. Please check:

    If these are intentionally filed as separate issues to address different layers of the same problem, that is fine — just flagging for maintainer awareness.

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions