Skip to content

Errors: AuthRequiredError message omits KALSHI_PRIVATE_KEY_PATH #215

Closed

Description

@TexasCoding

Summary

AuthRequiredError.__init__ default message reads:

Provide key_id + private_key_path when constructing the client, or set KALSHI_KEY_ID + KALSHI_PRIVATE_KEY environment variables.

Only KALSHI_PRIVATE_KEY (in-memory PEM) is mentioned. README, docs/authentication.md, and docs/environment-variables.md all present KALSHI_PRIVATE_KEY_PATH as the primary/most-common option (file on disk). A user hitting this error and following the prompt will not realize the path-based env var exists.

Location

kalshi/errors.py:22-27

Evidence

# kalshi/errors.py:22-27
super().__init__(
    message
    or "This endpoint requires authentication. "
    "Provide key_id + private_key_path when constructing the client, "
    "or set KALSHI_KEY_ID + KALSHI_PRIVATE_KEY environment variables.",
    status_code=None,
)
# docs/authentication.md:37-38 (primary recommended pattern)
export KALSHI_KEY_ID="..."
export KALSHI_PRIVATE_KEY_PATH="~/.kalshi/private_key.pem"

Recommended fix

Reword:

or "This endpoint requires authentication. "
"Provide key_id + private_key_path when constructing the client, "
"or set KALSHI_KEY_ID + (KALSHI_PRIVATE_KEY_PATH or KALSHI_PRIVATE_KEY) "
"environment variables. See https://texascoding.github.io/kalshi-python-sdk/authentication/",

Add test: test_auth_required_error_mentions_both_env_vars.

Severity & category

medium / documentation, dx

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

    documentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions