Skip to content

fix(strategies): return 404 for unbound or unknown strategies - #288

Open
piyushsinghgaur1 wants to merge 3 commits into
masterfrom
GH-287
Open

piyushsinghgaur1 wants to merge 3 commits into
masterfrom
GH-287

Conversation

@piyushsinghgaur1

Copy link
Copy Markdown
Contributor

Description

An unbound strategy factory or an unknown strategy name threw a plain Error, and the route turned that into a 500. Both cases now reject with HttpErrors.NotFound, so the client gets a 404.

The response body is now a general message: "The requested resource is not available". It no longer shows the binding key or the strategy name.

The provider had 13 copies of the same getSync and throw block. They now go through one private getFactory helper. The message lives in a new AuthErrorKeys.StrategyNotAvailable key.

Fixes #287

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • New integration test in src/__tests__/integration/action-sequence/passport-apple-oauth2/apple-oauth2-unbound.integration.ts. It covers an unbound Apple provider and an unknown strategy name. Both return 404 with the general message and no binding key in the body.
  • npm run build, npm run lint and npm test pass. The suite runs 126 tests.

Checklist:

  • Performed a self-review of my own code
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated. n/a, no public signatures changed
  • Any dependent changes have been merged and published in downstream modules

- An unbound strategy factory or an unknown strategy name now rejects
  with HttpErrors.NotFound instead of a plain Error, so the client gets a
  404, not a 500.
- The body is a general message. The binding key no longer shows up in it.
- Add AuthErrorKeys.StrategyNotAvailable for the message.
- Add an integration test for an unbound Apple provider and an unknown
  strategy name.

GH-287
@piyushsinghgaur1 piyushsinghgaur1 self-assigned this Oct 22, 2026
@piyushsinghgaur1 piyushsinghgaur1 added the bug Something isn't working label Oct 22, 2026
@namandeep-s1ngh

Copy link
Copy Markdown

Working fine now the api is giving 404
Screenshot 2026-10-22 at 7 10 07 PM

@a-ganguly
a-ganguly requested a balanced review from Copilot October 22, 2026 14:07
@namandeep-s1ngh
namandeep-s1ngh self-requested a review October 22, 2026 14:08

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Remove `async` from the process*Factory methods in AuthStrategyProvider.
None of them awaits anything, so SonarCloud flagged them (S7503). They
return the strategy directly now. value() is still async, so an unbound
factory or an unknown strategy name still rejects with the 404.

GH-287
Run npm audit fix to update brace-expansion, fast-uri, handlebars,
js-yaml, msgpack5 and proxy-addr, and move the undici override from
6.28.0 to 6.28.1. A trivy scan for HIGH and CRITICAL findings is clean
afterwards.

GH-287
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbound auth strategy returns 500 instead of 404

3 participants