GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(schema): ModelAlias alias lookups match Object.prototype members — toString/constructor names crash the #410/#413 validation with TypeError · Issue #414 · developing-today-forks/opencode

fix(schema): ModelAlias alias lookups match Object.prototype members — toString/constructor names crash the #410/#413 validation with TypeError #414

New issue
Copy link
New issue
Copy link
Closed
#415
Closed
fix(schema): ModelAlias alias lookups match Object.prototype members — toString/constructor names crash the #410/#413 validation with TypeError#414
#415
Copy link
Labels
app/schemaPackage: schema (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

Description

@dezren39
dezren39
opened on Oct 25, 2026
Issue body actions

Summary

In ModelAlias.resolveRef (packages/schema/src/model-alias.ts), alias lookups read inherited Object.prototype members as if they were configured aliases. A model, provider, or variant name that happens to equal a prototype member (toString, constructor, hasOwnProperty, valueOf, __proto__) therefore produces a non-string "target", and the validation added in PRs #410 and #413 crashes with a TypeError instead of resolving normally or throwing Invalid model reference.

This is visible in the #410/#413 diffs themselves: both PRs changed/introduced guards that assume a lookup returns string | undefined —

  • PR fix(schema): reject empty model alias targets #413 (commit 837c4e0e1dfb, merge 0fec462129): the three model-alias lookups at model-alias.ts:83 (global), :109 (scoped under original provider) and :143 (scoped under resolved provider) now check !== undefined and assign the value to current.
  • PR fix(schema): validate provider and variant alias targets #410 (commit e1caf59543f5, merge d0ba1110fb): the provider-alias lookup at model-alias.ts:132 checks !== undefined and then calls providerAlias.includes(...); the variant caller at model-alias.ts:194 calls finalVariant.includes("#") on the value returned by resolveVariant, whose bare-key lookup at model-alias.ts:240 uses the in operator (if (variant in variantAliases)), which also matches inherited members.

Plain-object alias maps (object literals in tests, and the records produced by config decoding in packages/core/src/config/normalize.ts) inherit from Object.prototype, so aliases.models["toString"], aliases.providers["toString"] and "toString" in aliases.variants are all truthy/defined even when the user never configured such an alias.

Evidence (verified on current main 0fec462129, the #413 merge)

Probe (bun, importing packages/schema/src/model-alias.ts directly):

resolve({ models: { other: "openai/gpt-4o" } }, "toString")
  THROWS TypeError: current.indexOf is not a function
resolve({ models: { other: "openai/gpt-4o" } }, "constructor")
  THROWS TypeError: current.indexOf is not a function
resolve({ models: { other: "openai/gpt-4o" } }, "hasOwnProperty")
  THROWS TypeError: current.indexOf is not a function
resolve({ providers: { other: "openai" } }, "toString/model")
  THROWS TypeError: providerAlias.includes is not a function
resolve({ providers: { other: "openai" } }, "constructor/model")
  THROWS TypeError: providerAlias.includes is not a function
resolve({ variants: { hi: "high" } }, "openai/gpt-4o#toString")
  THROWS TypeError: finalVariant.includes is not a function
resolve({ variants: { hi: "high" } }, "openai/gpt-4o#constructor")
  THROWS TypeError: finalVariant.includes is not a function
resolve({ variants: { hi: "high" } }, "openai/gpt-4o#__proto__")
  THROWS TypeError: finalVariant.includes is not a function

Contrast with the no-alias path, which handles the same names cleanly:

resolve(undefined, "openai/gpt-4o#toString")  => "openai/gpt-4o#toString"   // real variant passes through
resolve(undefined, "toString")               THROWS Error: Invalid model reference: toString

So with any alias map configured, a bare model named toString, a provider named toString, or a variant named toString/constructor/__proto__ crashes the resolver with a TypeError, where the no-alias parser either passes the name through or raises the documented Invalid model reference error. Callers in ModelResolver and the session runner catch all errors, so in those paths the crash is silently swallowed and alias resolution is abandoned for that request; direct callers (e.g. packages/cli/src/session-target.ts) get an unexplained TypeError.

Distinct from #412 (whitespace-only alias targets): that issue is about configured string targets; this one is about lookups returning inherited non-string values for names that were never configured at all.

Why it matters

Alias resolution sits on the model-selection path for every configured deployment. Names colliding with Object.prototype members are not exotic in generated or user-authored config (a variant literally named e.g. constructor is legal input to the no-alias parser today), and the failure mode — a TypeError from inside validation code, or silently skipped alias resolution where callers catch-all — is far from the actual cause. The #410/#413 hardening made the resolver stricter for configured targets; the lookups themselves should be own-property lookups so unconfigured names behave exactly as they do with no aliases.

Single-repo: the ModelAlias resolver lives only in developing-today/opencode (packages/schema/src/model-alias.ts).

Acceptance criteria

  • Alias lookups in resolveRef/resolveVariant only match own properties of the alias maps (e.g. Object.hasOwn guards or typeof === "string" checks): toString, constructor, hasOwnProperty, valueOf, and __proto__ as a model, provider, or bare variant name behave exactly as they do on the no-alias path (pass through where the plain parser passes them through, Invalid model reference where it rejects) — never a TypeError.
  • A genuinely configured alias whose key is one of those names and whose target is a string still resolves (own-property check, not a blocklist).
  • New tests in packages/core/test/model-alias.test.ts cover at least: bare model toString with a models map present, provider toString/model with a providers map present, and variant openai/gpt-4o#toString with a variants map present.
  • Existing model-alias tests (24/24 on main 0fec462129) all still pass.

Activity

  1. dezren39
    closed this as completedin #415on Oct 25, 2026
  2. dezren39
    added a commit that references this issue on Oct 25, 2026

    docs: record the #414/#412 and #416 completions in ROADMAP Done (#419)

    954ff7c
  3. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    developing-today-fleetBot
    on Nov 24, 2026 – with developing.today fleet
    More actions

    AUDIT-7 Lane 2 slice 3 — closing evidence. Verified against the issue body and merged implementation PR(s):

    • PR #415 — fix(schema): use own-property alias lookups and reject padded alias targets (merged 2026-10-25)

    The issue had zero comments in the fresh pre-action read; this comment records the missing close evidence.

  4. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    app/schemaPackage: schema (pkgs/ or apps/ in this repo)
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/schemaPackage: schema (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.