Skip to content

feat(errors): add SignatureVerificationError - #48

Merged
codebestia merged 2 commits into
ShadeProtocol:mainfrom
Tijesunimi004:feat/signature-verification-error
Jul 24, 2026
Merged

feat(errors): add SignatureVerificationError#48
codebestia merged 2 commits into
ShadeProtocol:mainfrom
Tijesunimi004:feat/signature-verification-error

Conversation

@Tijesunimi004

@Tijesunimi004 Tijesunimi004 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds SignatureVerificationError(ShadeError) to errors.py, closes #34.

  • Stores the raw Shade-Signature header value as received (header attribute).
  • SignatureVerificationError.from_mismatch(header=...) factory builds the error with a message explaining the likely causes (wrong webhook secret or payload modified in transit), mirroring the existing NotFoundError.from_response / InvalidRequestError.from_response pattern.
  • The expected signature is never accepted as an argument anywhere on this class, so it cannot end up in the exception message or attributes.
  • Exported from the shade package root.

This only adds the error type per the issue's proposed steps. Webhook.construct_event() (issue #66) will raise it once implemented.

Test plan

  • pytest tests/test_errors.py — new tests cover: inherits from ShadeError, header is optional, from_mismatch stores the header, the message mentions both "secret" and "payload", and the expected signature never appears in the message or as an attribute.
  • Full suite (pytest) passes: 137 passed.
  • flake8 . --count --select=E9,F63,F7,F82 (CI's hard-fail lint check) passes clean.

Summary by CodeRabbit

  • New Features

    • Added a public SignatureVerificationError exception for webhook signature/HMAC verification failures.
    • Error details can optionally include the received signature header and standardized guidance for signature mismatches.
    • The exception is now available directly from the shade package.
  • Tests

    • Added coverage for subclassing from ShadeError, optional header behavior, mismatch message construction, and ensuring no expected-signature values are exposed.

Raised for webhook signature mismatches. Stores the received
Shade-Signature header and, via the from_mismatch factory, produces
a message explaining the likely causes (wrong secret or tampered
payload) without ever exposing the expected HMAC value.
Copilot AI review requested due to automatic review settings July 23, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new SignatureVerificationError represents webhook signature mismatches, stores an optional raw signature header, exposes a mismatch factory, and is publicly exported from shade. Tests cover inheritance, messaging, header handling, and signature secrecy.

Changes

Signature verification error

Layer / File(s) Summary
Signature verification exception
src/shade/errors.py
Defines SignatureVerificationError with optional header storage and a standardized mismatch message factory.
Public export and behavior validation
src/shade/__init__.py, tests/test_errors.py
Exports the exception at the package root and tests inheritance, header handling, message contents, and protection of expected signatures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding SignatureVerificationError.
Description check ✅ Passed The description covers the summary, issue link, motivation/context, and test plan; only non-critical template sections are missing.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codebestia

Copy link
Copy Markdown
Contributor

Hello @Tijesunimi004
Please properly link the issue using the Closes keyword and fix the merge conflicts.
Thanks.

@Tijesunimi004

Copy link
Copy Markdown
Contributor Author

All fixed and done @codebestia

@codebestia codebestia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you for your contribution.

@codebestia
codebestia merged commit 475b970 into ShadeProtocol:main Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SignatureVerificationError

3 participants