Skip to content

Add API key format validation #4

Open

Description

@codebestia

Description:

API keys must conform to a format (e.g. pk_live_, sk_live_, pk_test_, sk_test_ prefixes). Catching a malformed key before the first network call saves developers from cryptic 401 errors. Validation should also enforce that a live key is not accidentally used with the sandbox environment, and vice versa.

Proposed Steps:

  • Write a validate_api_key(key: str, environment: Environment) function in config.py.
  • Check prefix, minimum length, and character set.
  • Warn (but do not raise) when a test_ key is used with PRODUCTION or a live_ key with SANDBOX.
  • Call this in the ShadeClient constructor and in the global setter.

Acceptance Criteria:

  • A key not matching the expected format raises AuthenticationError at configuration time, not at request time.
  • A pk_test_ key used with environment="production" emits a UserWarning.
  • A valid sk_live_ key passes validation without error.
  • None or empty string raises AuthenticationError immediately.

Activity

  1. yeiner-45 commented on Jun 20, 2026

    @yeiner-45

    Hi! I would love to take on this issue. Validating API keys client-side is an excellent way to improve the developer experience and prevent confusing 401 network errors. I have a strong background in software logic, validation patterns, and exception handling. I can easily implement the validate_api_key logic in config.py using clean string manipulation and character set checks, ensure the proper UserWarning is emitted for environment mismatches without breaking execution, and integrate it into the ShadeClient constructor. Ready to work on this right away!

  2. xJeffx23 commented on Jun 20, 2026

    @xJeffx23
    Contributor

    Hello!

    My name is Jefferson, and I have been contributing to open-source projects for over a year. I have participated in multiple hackathons and have experience working with SDKs, API integrations, and developer-focused tooling.

    I would like to work on this issue because validating API keys at configuration time provides a much better developer experience than surfacing errors only after a request is made. Early validation can prevent common configuration mistakes and make authentication issues easier to diagnose.

    My plan would be to implement a validate_api_key function that validates prefixes, minimum length, and allowed characters, while also checking for environment mismatches and emitting warnings when appropriate. I would integrate the validation into the client initialization flow and global configuration setters, then add tests covering invalid keys, empty values, warning scenarios, and valid production keys.

    I would greatly appreciate the opportunity to contribute to the project. Thank you for your time and consideration!

  3. grantfox-oss commented on Jun 25, 2026

    @grantfox-oss

    🦊 GrantFox — @yeiner-45 has been assigned to this issue as part of the Official Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #4)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  4. codebestia commented on Jun 29, 2026

    @codebestia
    ContributorAuthor

    Hello @yeiner-45
    What is the update with this task?
    Please raise a PR within 6 hours.

  5. grantfox-oss commented on Jul 20, 2026

    @grantfox-oss

    🦊 GrantFox — @yeiner-45 has been assigned to this issue as part of the Official Campaign | FWC26 campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #4)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  6. codebestia commented on Jul 29, 2026

    @codebestia
    ContributorAuthor

    Hello @yeiner-45
    What is the update with this issue?
    Please raise a PR within 12 hours.

  7. guptakumarranjeet150 commented on Sep 13, 2026

    @guptakumarranjeet150

    Hi maintainers,

    I would like to resolve this issue. Here is my proposed execution plan:

    • Implementation: Structure backend handlers for Add API key format validation with strict input validation, proper HTTP error codes, and idempotent execution.
    • Testing & Verification: Cover implementation with end-to-end integration tests for standard and edge-case inputs.
    • Delivery: Ready to ship a thoroughly tested PR within 12–24 hours with passing CI.

    I am ready to start immediately—please assign this to me!

  8. rupesh-kumar-sah commented on Sep 30, 2026

    @rupesh-kumar-sah

    Hey team,

    I can tackle Add API key format validation. Proposed implementation roadmap:

    • Analysis: Inspect current behavior and edge cases in ShadeProtocol/shade-python
    • Core Implementation: Build out the handlers for Add API key format validation ensuring proper HTTP status codes and error propagation.
    • Quality Assurance: Add integration test suites for standard invocations and boundary/error conditions.

    Ready to deliver a clean, tested PR within 12–24 hours. Please assign!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions