unslothai/unsloth · error · ValueError

Bad candidate spec fragment '{part}' (expected key=value)

Error message

Bad candidate spec fragment '{part}' (expected key=value)

What it means

Thrown by ensureCodexProvider (chat-providers-dialog.tsx:588-596) when the user triggers ChatGPT OAuth but the resolved provider registry entry's auth_kind is not 'chatgpt_oauth'. The function maps the selected providerType through toExternalBackendProviderType and looks up registryByType; only registry entries explicitly marked auth_kind === 'chatgpt_oauth' (i.e. Codex) can go through the ChatGPT authorization flow. Everything else (api_key providers) is rejected before createProviderConfig runs.

Source

Thrown at scripts/video_quality.py:270

        chunks = [c.to_ndarray() for c in container.decode(container.streams.audio[0])]
        if chunks:
            audio = np.concatenate([c.reshape(c.shape[0], -1).mean(axis = 0) for c in chunks])
    container.close()
    return frames, audio


# ── configuration plumbing ───────────────────────────────────────────────────


def parse_spec(spec: str) -> dict[str, str]:
    """'k=v;k=v' (or space-free 'k=v,k=v') -> dict; empty string -> {} (pure base)."""
    out: dict[str, str] = {}
    for part in spec.replace(",", ";").split(";"):
        part = part.strip()
        if not part:
            continue
        if "=" not in part:
            raise ValueError(f"Bad candidate spec fragment '{part}' (expected key=value)")
        key, value = part.split("=", 1)
        out[key.strip()] = value.strip()
    return out


def spec_label(spec: dict[str, str]) -> str:
    if not spec:
        return "base"
    return ",".join(
        f"{k}={Path(v).name if k == 'gguf_filename' else v}" for k, v in sorted(spec.items())
    )


def run_config(
    backend: Any, args: Any, spec: dict[str, str], workdir: Path, name: str
) -> dict[str, Any]:
    """Load per spec, generate the fixed clip, unload. Returns frames/audio/cost."""
    import torch

View on GitHub (pinned to 203007d190)

Solutions

  1. Switch the connection type to the Codex provider in the dialog before starting ChatGPT authorization.
  2. For api-key providers, enter the API key instead — OAuth does not apply.
  3. If the registry list appears empty or stale, reload the providers dialog so the registry refetches.
  4. As a developer, gate the OAuth button's disabled state on selectedProviderContract?.auth_kind === 'chatgpt_oauth' so the path is unreachable for other types.

Example fix

// before
<Button onClick={startChatGPTOAuth}>Sign in with ChatGPT</Button>

// after
<Button disabled={selectedProviderContract?.auth_kind !== "chatgpt_oauth"} onClick={startChatGPTOAuth}>Sign in with ChatGPT</Button>
Defensive patterns

Strategy: type-guard

Validate before calling

const supportsChatGptOAuth = (registryByType: Map<string, ProviderRegistryEntry>, providerType: string): boolean =>
  registryByType.get(toExternalBackendProviderType(providerType))?.auth_kind === 'chatgpt_oauth';

Type guard

function isChatGptOAuthEntry(entry: ProviderRegistryEntry | undefined): entry is ProviderRegistryEntry & { auth_kind: 'chatgpt_oauth' } {
  return entry?.auth_kind === 'chatgpt_oauth';
}

Try / catch

try {
  await ensureCodexProvider();
} catch (error) {
  if (error instanceof Error && error.message === 'This connection does not support ChatGPT authorization.') {
    toast.info('Switch to the Codex connection to use ChatGPT sign-in.');
  } else throw error;
}

Prevention

When it happens

Trigger: Clicking 'Sign in with ChatGPT' / the OAuth button while providerType is an api-key provider (OpenRouter, Groq, a custom OpenAI-compatible gateway) or an unrecognized type whose registryByType.get(...) returns undefined (entry?.auth_kind is then undefined !== 'chatgpt_oauth').

Common situations: UI state desync where the OAuth button renders for a non-OAuth provider type; editing an existing non-Codex provider (editingProviderId set) and invoking the Codex OAuth path; a registry fetch that failed leaving registryByType empty.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/922c8448718680dd. Report an issue: GitHub.