Add ApiKey#revoked? to match Warehouse::ApiToken - #96
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ApiKeyis a brand-new auth model whose predicate surface silently diverges from its siblingWarehouse::ApiToken— the next person to writeapi_key.revoked?in a controller or Doorkeeper-adjacent path gets a 500 in an auth flow instead of a boolean.revoked_at, arevoke!writer, and anactivescope, but norevoked?reader, soapi_key.revoked?raisesNoMethodError: undefined method 'revoked?' for an instance of ApiKey.rails runner, not a request path. Views dodge it by using the Rails-generatedrevoked_at?attribute predicate. This is a latent gap, not a live outage.Changes
ApiKey#revoked?returningrevoked_at.present?, mirroringWarehouse::ApiToken#revoked?exactly.test/models/api_key_test.rb.Predicate surface
Warehouse::ApiTokenApiKey(before)ApiKey(after)revoked?has_scope?revoked?was the only applicable mismatch;has_scope?doesn't apply sinceApiKeyhas no scopes concept.Notes
ApiKeytest's fixtures andissue!pattern; CI will run it.Created with PostHog Desktop from this inbox report.