langchain-ai/deepagents · error · ValueError
Provider name cannot be empty
Error message
Provider name cannot be empty
What it means
`set_stored_key` validates its inputs before touching the store and raises `ValueError` when the `provider` argument is empty (empty string or None). Provider names are the dictionary keys of the credential store, so an empty key would produce an unusable entry.
Source
Thrown at libs/code/deepagents_code/auth_store.py:471
only for the `langsmith` tracing service. Whitespace is stripped;
blank/`None` stores no project, meaning traces use the default
project.
Returns:
A `WriteOutcome` whose `warnings` tuple lists chmod failures the
caller should surface to the user. Empty on a clean save.
Raises:
ValueError: If `provider` or the stripped `key` is empty, or a non-empty
`project` is paired with a provider other than the `langsmith`
service.
RuntimeError: If the credential file is corrupt and cannot be read, or
the new file cannot be written (e.g. no disk space or an
unwritable state directory).
""" # noqa: DOC502 - `RuntimeError` re-raised from `_read_raw`/`_write_raw_or_raise`
if not provider:
msg = "Provider name cannot be empty"
raise ValueError(msg)
cleaned = key.strip()
if not cleaned:
msg = "API key cannot be empty"
raise ValueError(msg)
data = _read_raw() or {}
creds = data.get("credentials")
if not isinstance(creds, dict):
creds = {}
entry: dict[str, str] = {
"type": "api_key",
"key": cleaned,
"added_at": datetime.now(tz=UTC).isoformat(timespec="seconds"),
}
cleaned_base_url = base_url.strip() if base_url else ""
if cleaned_base_url:
entry["base_url"] = cleaned_base_url
cleaned_project = project.strip() if project else ""
if cleaned_project:View on GitHub (pinned to a1af029e6e)
Solutions
- Pass a non-empty provider name, e.g. set_stored_key("anthropic", key).
- Trim and check the provider string before calling; reject blank input in your own form/parser.
- If calling from `/auth`, enter the provider name when prompted instead of submitting empty input.
Example fix
// before
set_stored_key(provider.strip(), key) # provider = "" -> ValueError
// after
provider = provider.strip()
if not provider:
raise SystemExit("usage: /auth set <provider> <key>")
set_stored_key(provider, key) Defensive patterns
Strategy: validation
Validate before calling
def require_provider(provider: str) -> str:
cleaned = (provider or "").strip()
if not cleaned:
raise UsageError("provider name is required")
return cleaned
# call site
set_stored_key(require_provider(provider), key) Type guard
def _is_nonempty_str(value: object) -> TypeGuard[str]:
return isinstance(value, str) and bool(value.strip()) Try / catch
try:
set_stored_key(provider, key)
except ValueError as exc:
if "Provider name cannot be empty" in str(exc):
print("usage: /auth set <provider> <key>")
else:
raise Prevention
- Strip and validate CLI/form input before passing provider names.
- Fail fast on empty env-derived values instead of passing them through.
- Keep a canonical provider-name list and validate against it in your own UI.
- When scripting /auth from stdin, check that each expected field is present.
When it happens
Trigger: Calling set_stored_key("") or set_stored_key(None, ...) directly, or via the `/auth set` flow (`_run_set` / `on_input_submitted`) when the user submits an empty provider name.
Common situations: Scripting the CLI from stdin and piping an empty first field; a UI form allowing blank provider input; string slicing/formatting bugs producing an empty provider variable.
Related errors
- API key cannot be empty
- project is only valid for the langsmith service, not {provid
- suffix must be empty or a short extension such as .md
- DiffStats counts cannot be negative, got additions={self.add
- Unknown external event kind: {self.kind!r}
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/e6697933744c9a66.
Report an issue: GitHub.