{"record":{"id":"e6697933744c9a66","repo":"langchain-ai/deepagents","slug":"provider-name-cannot-be-empty","errorCode":null,"errorMessage":"Provider name cannot be empty","messagePattern":"Provider name cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/auth_store.py","lineNumber":471,"sourceCode":"            only for the `langsmith` tracing service. Whitespace is stripped;\n            blank/`None` stores no project, meaning traces use the default\n            project.\n\n    Returns:\n        A `WriteOutcome` whose `warnings` tuple lists chmod failures the\n        caller should surface to the user. Empty on a clean save.\n\n    Raises:\n        ValueError: If `provider` or the stripped `key` is empty, or a non-empty\n            `project` is paired with a provider other than the `langsmith`\n            service.\n        RuntimeError: If the credential file is corrupt and cannot be read, or\n            the new file cannot be written (e.g. no disk space or an\n            unwritable state directory).\n    \"\"\"  # noqa: DOC502 - `RuntimeError` re-raised from `_read_raw`/`_write_raw_or_raise`\n    if not provider:\n        msg = \"Provider name cannot be empty\"\n        raise ValueError(msg)\n    cleaned = key.strip()\n    if not cleaned:\n        msg = \"API key cannot be empty\"\n        raise ValueError(msg)\n    data = _read_raw() or {}\n    creds = data.get(\"credentials\")\n    if not isinstance(creds, dict):\n        creds = {}\n    entry: dict[str, str] = {\n        \"type\": \"api_key\",\n        \"key\": cleaned,\n        \"added_at\": datetime.now(tz=UTC).isoformat(timespec=\"seconds\"),\n    }\n    cleaned_base_url = base_url.strip() if base_url else \"\"\n    if cleaned_base_url:\n        entry[\"base_url\"] = cleaned_base_url\n    cleaned_project = project.strip() if project else \"\"\n    if cleaned_project:","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/auth_store.py#L453-L489","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nset_stored_key(provider.strip(), key)  # provider = \"\" -> ValueError\n// after\nprovider = provider.strip()\nif not provider:\n    raise SystemExit(\"usage: /auth set <provider> <key>\")\nset_stored_key(provider, key)","handlingStrategy":"validation","validationCode":"def require_provider(provider: str) -> str:\n    cleaned = (provider or \"\").strip()\n    if not cleaned:\n        raise UsageError(\"provider name is required\")\n    return cleaned\n# call site\nset_stored_key(require_provider(provider), key)","typeGuard":"def _is_nonempty_str(value: object) -> TypeGuard[str]:\n    return isinstance(value, str) and bool(value.strip())","tryCatchPattern":"try:\n    set_stored_key(provider, key)\nexcept ValueError as exc:\n    if \"Provider name cannot be empty\" in str(exc):\n        print(\"usage: /auth set <provider> <key>\")\n    else:\n        raise","preventionTips":["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."],"tags":["auth","validation","input-error"],"backgroundTag":"empty-required-argument","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}