[PR #5325] [MERGED] fix(api-key): remove incorrect usage tracking in updateApiKey #5929

Closed
opened 2026-03-13 12:41:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5325
Author: @ahmed-abdat
Created: 10/15/2025
Status: Merged
Merged: 10/17/2025
Merged by: @Bekacru

Base: canaryHead: fix/api-key-lastrequest-bug


📝 Commits (3)

  • 5fb39dd fix(api-key): remove incorrect usage tracking in updateApiKey
  • 7e60bf9 test(api-key): remove inline comments to match repository patterns
  • 275b0d9 Merge branch 'canary' into fix/api-key-lastrequest-bug

📊 Changes

2 files changed (+103 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/api-key/api-key.test.ts (+103 -0)
📝 packages/better-auth/src/plugins/api-key/routes/update-api-key.ts (+0 -1)

📄 Description

Fixes #5309

Problem

The updateApiKey endpoint incorrectly updates lastRequest timestamp and auto-decrements remaining counter on every configuration update, conflating management operations with actual API key usage.

Solution

Removed lines that unconditionally set lastRequest and auto-decrement remaining from updateApiKey. These fields should only be modified during actual API key usage (verifyApiKey), not during configuration updates.

Tests

  • updateApiKey does not modify lastRequest
  • updateApiKey does not auto-decrement remaining
  • Explicit remaining updates still work
  • verifyApiKey still correctly tracks usage (regression)
  • All existing tests pass

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5325 **Author:** [@ahmed-abdat](https://github.com/ahmed-abdat) **Created:** 10/15/2025 **Status:** ✅ Merged **Merged:** 10/17/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/api-key-lastrequest-bug` --- ### 📝 Commits (3) - [`5fb39dd`](https://github.com/better-auth/better-auth/commit/5fb39ddf726c80e7b1fb8ee51850ddfbcac2dc05) fix(api-key): remove incorrect usage tracking in updateApiKey - [`7e60bf9`](https://github.com/better-auth/better-auth/commit/7e60bf9d671cb05f01f61c6737415e1e7a4fb002) test(api-key): remove inline comments to match repository patterns - [`275b0d9`](https://github.com/better-auth/better-auth/commit/275b0d9f4ea50c603ccd19bebf4edf1f273caa17) Merge branch 'canary' into fix/api-key-lastrequest-bug ### 📊 Changes **2 files changed** (+103 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/api-key/api-key.test.ts` (+103 -0) 📝 `packages/better-auth/src/plugins/api-key/routes/update-api-key.ts` (+0 -1) </details> ### 📄 Description Fixes #5309 ### Problem The `updateApiKey` endpoint incorrectly updates `lastRequest` timestamp and auto-decrements `remaining` counter on every configuration update, conflating management operations with actual API key usage. ### Solution Removed lines that unconditionally set `lastRequest` and auto-decrement `remaining` from updateApiKey. These fields should only be modified during actual API key usage (verifyApiKey), not during configuration updates. ### Tests - [x] updateApiKey does not modify lastRequest - [x] updateApiKey does not auto-decrement remaining - [x] Explicit remaining updates still work - [x] verifyApiKey still correctly tracks usage (regression) - [x] All existing tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:41:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5929