Skip to content

Commit f3dcfcc

Browse files
authored
Add new HCaptcha error codes (#16742)
1 parent 5574f8a commit f3dcfcc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

warehouse/captcha/hcaptcha.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,23 @@ class InvalidInputResponseError(HCaptchaError):
4343
pass
4444

4545

46+
class ExpiredInputResponseError(HCaptchaError):
47+
pass
48+
49+
50+
class AlreadySeenResponseError(HCaptchaError):
51+
pass
52+
53+
4654
class BadRequestError(HCaptchaError):
4755
pass
4856

4957

50-
class InvalidOrAlreadySeenResponseError(HCaptchaError):
58+
class MissingRemoteIPError(HCaptchaError):
59+
pass
60+
61+
62+
class InvalidRemoteIPError(HCaptchaError):
5163
pass
5264

5365

@@ -63,16 +75,25 @@ class UnexpectedError(HCaptchaError):
6375
pass
6476

6577

78+
class InvalidOrAlreadySeenResponseError(HCaptchaError):
79+
pass
80+
81+
6682
# https://docs.hcaptcha.com/#siteverify-error-codes-table
6783
ERROR_CODE_MAP = {
6884
"missing-input-secret": MissingInputSecretError,
6985
"invalid-input-secret": InvalidInputSecretError,
7086
"missing-input-response": MissingInputResponseError,
7187
"invalid-input-response": InvalidInputResponseError,
72-
"invalid-or-already-seen-response": InvalidOrAlreadySeenResponseError,
88+
"expired-input-response": ExpiredInputResponseError,
89+
"already-seen-response": AlreadySeenResponseError,
90+
"bad-request": BadRequestError,
91+
"missing-remoteip": MissingRemoteIPError,
92+
"invalid-remoteip": InvalidRemoteIPError,
7393
"not-using-dummy-passcode": NotUsingDummyPasscodeError,
7494
"sitekey-secret-mismatch": SitekeySecretMismatchError,
75-
"bad-request": BadRequestError,
95+
# Maybe legacy?
96+
"invalid-or-already-seen-response": InvalidOrAlreadySeenResponseError,
7697
}
7798

7899

0 commit comments

Comments
 (0)