mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-10-19 15:44:27 +00:00
docs(license): say Keygen ignores the case of metadata keys
Keygen v1.7.2 snake-cases every request key on the way in (config/initializers/jsonapi.rb) and every metadata filter key (License.search_metadata), and camelCases keys in responses, so checkoutSessionId and checkout_session_id are one key. What returns an empty list is a key with a different word. The keygen.py docstring, the models.py comment and portal.md said filters were case-sensitive, and the docstring cited a live contract test that does not exist yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0e1ce03d7c
commit
6d7cf272ff
3 changed files with 7 additions and 8 deletions
|
|
@ -67,7 +67,7 @@ Fulfilment also writes the license's Keygen id onto the Stripe customer as `keyg
|
|||
| `stripeCustomerId` | Stripe purchases | the Stripe customer a refund comes from |
|
||||
| `checkoutSessionId` | Stripe purchases | the success page, support corrections, refund → suspend |
|
||||
|
||||
Keygen camelCases metadata keys in filter queries, and a misspelled filter returns an empty list rather than an error, which reads as "no license". The spellings live in `app/license/models.py`, except that `create_license()` in `keygen.py` writes `plan` and `email` as literals.
|
||||
Keygen snake-cases metadata keys when it stores them and when it filters on them, and camelCases them in responses ([`jsonapi.rb`](https://github.com/keygen-sh/keygen-api/blob/v1.7.2/config/initializers/jsonapi.rb#L5-L11), [`license.rb`](https://github.com/keygen-sh/keygen-api/blob/v1.7.2/app/models/license.rb#L337-L338)), so `checkoutSessionId` and `checkout_session_id` are one key. A key with a different word is what goes wrong: it returns an empty list rather than an error, which reads as "no license". The spellings live in `app/license/models.py`, except that `create_license()` in `keygen.py` writes `plan` and `email` as literals.
|
||||
|
||||
Certificates are never stored. Every delivery, whether success page, purchase mail or resend, checks out a fresh file with `{"meta": {"ttl": null}}`, so two files for one license differ in `meta.issued` and share a key. `ttl: null` matters because the app never refreshes, and Keygen's default 30-day TTL would kill every file a month after purchase.
|
||||
|
||||
|
|
|
|||
|
|
@ -227,11 +227,10 @@ async def list_licenses(
|
|||
) -> list[dict[str, Any]]:
|
||||
"""List licenses matching every given metadata filter.
|
||||
|
||||
Keygen camelCases metadata keys in filter queries, so callers must pass
|
||||
``checkoutSessionId``, not ``checkout_session_id``. A wrong key returns an
|
||||
empty list rather than an error, which reads as "no license exists" and
|
||||
would issue a duplicate -- which is why this is stated here and covered by
|
||||
the live contract test.
|
||||
Keygen snake-cases metadata keys on write and in filters, so case cannot
|
||||
miss: ``checkoutSessionId`` and ``checkout_session_id`` are one key. A key
|
||||
with a different word returns an empty list rather than an error, which
|
||||
reads as "no license exists" and would issue a duplicate.
|
||||
"""
|
||||
params: dict[str, str] = {"limit": str(limit)}
|
||||
for key, value in (metadata or {}).items():
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ from app.license.keygen import LicensePlan
|
|||
LicenseSource = Literal["stripe", "trial", "enterprise"]
|
||||
PAID_STATUSES = {"paid", "no_payment_required"}
|
||||
|
||||
# Keygen camelCases metadata keys in filter queries, so these are the spellings
|
||||
# both writes and lookups must use.
|
||||
# The one spelling of each key, for writes and lookups alike. Keygen ignores
|
||||
# case, since it snake-cases keys, but a key with a different word finds nothing.
|
||||
META_EMAIL = "email"
|
||||
META_PLAN = "plan"
|
||||
META_CUSTOMER = "stripeCustomerId"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue