Skip to content

Add ApiKey#revoked? to match Warehouse::ApiToken - #96

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixapi-keys-add-missing-apikeyrevoked-357b19
Draft

Add ApiKey#revoked? to match Warehouse::ApiToken#96
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixapi-keys-add-missing-apikeyrevoked-357b19

Conversation

@posthog

@posthog posthog Bot commented Aug 7, 2026

Copy link
Copy Markdown

Problem

  • ApiKey is a brand-new auth model whose predicate surface silently diverges from its sibling Warehouse::ApiToken — the next person to write api_key.revoked? in a controller or Doorkeeper-adjacent path gets a 500 in an auth flow instead of a boolean.
  • It ships revoked_at, a revoke! writer, and an active scope, but no revoked? reader, so api_key.revoked? raises NoMethodError: undefined method 'revoked?' for an instance of ApiKey.
  • Low blast radius today: surfaced once via a one-off rails runner, not a request path. Views dodge it by using the Rails-generated revoked_at? attribute predicate. This is a latent gap, not a live outage.

Changes

  • Add ApiKey#revoked? returning revoked_at.present?, mirroring Warehouse::ApiToken#revoked? exactly.
  • Cover it in test/models/api_key_test.rb.

Predicate surface

Predicate Warehouse::ApiToken ApiKey (before) ApiKey (after)
revoked?
has_scope? n/a — no scopes column n/a

revoked? was the only applicable mismatch; has_scope? doesn't apply since ApiKey has no scopes concept.

Notes

  • Ruby wasn't available in the fix environment (repo pins ruby-4.0.2, no version manager present), so the suite wasn't executed here. The new test mirrors the existing passing ApiKey test's fixtures and issue! pattern; CI will run it.

Created with PostHog Desktop from this inbox report.

ApiKey shipped a revoked_at column, a revoke! writer, and an active scope but no revoked? reader, so `api_key.revoked?` raised NoMethodError. The sibling Warehouse::ApiToken defines revoked? as revoked_at.present?; this mirrors it and adds a test.

Generated-By: PostHog Code
Task-Id: b15a7a8d-171f-4b3d-9c96-563794160d92
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.

0 participants