Skip to content

Remove a duplicated next call - #872

Merged
slifty merged 2 commits into
mainfrom
noissue-cleanup
Sep 16, 2026
Merged

slifty merged 2 commits into
mainfrom
noissue-cleanup

Conversation

@slifty

@slifty slifty commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes a bug that Claude noticed when I was working on the token introspection issue (#870).

Specifically there was a case where next could be called twice, which is not something we want to happen because express is expecting each request to result in a linear next chain.

It also noticed a duplicated test so I figured that's worth taking out at the same time.

@slifty
slifty requested review from liam-lloyd and a lite review from Copilot September 15, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues remain.

Pull request overview

Fixes duplicate Express next calls in authentication middleware and removes redundant test coverage.

Changes:

  • Corrects authentication fallback control flow.
  • Adds regression coverage for a single next call.
  • Removes duplicated tests.
File summaries
File Description
packages/api/src/middleware/authentication.ts Prevents duplicate next calls.
packages/api/src/middleware/authentication.test.ts Adds regression coverage and removes duplicate tests.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (88fbc21) to head (31e2aa0).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #872   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files          99       99           
  Lines        2807     2808    +1     
  Branches      538      539    +1     
=======================================
+ Hits         2769     2770    +1     
  Misses         38       38           
Flag Coverage Δ
api 98.64% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liam-lloyd
liam-lloyd self-requested a review September 16, 2026 00:26
Comment thread packages/api/src/middleware/authentication.ts
The extractUserIsAdminFromAuthToken describe block appeared twice, word
for word, so its cases ran twice without adding any coverage.

Claude-Session: 237cac91-cf26-4d1c-81ae-093e451be49e
When a user token failed and the admin token succeeded, the middleware
called next() and then fell through to next(err). That passed the user
token's 401 on to the error handler after the request had already moved
on to the route.

Claude-Session: 237cac91-cf26-4d1c-81ae-093e451be49e
@slifty
slifty merged commit d32a7a9 into main Sep 16, 2026
34 checks passed
@slifty
slifty deleted the noissue-cleanup branch September 16, 2026 17:31
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.

3 participants