Skip to content

Consolidate shouldFallbackToLocalRegistry into src/utils.js - #633

Merged
Abdulazeem-code merged 1 commit into
Abdulazeem-code:mainfrom
Tijesunimi004:refactor/dedupe-fallback-check
Aug 29, 2026
Merged

Consolidate shouldFallbackToLocalRegistry into src/utils.js#633
Abdulazeem-code merged 1 commit into
Abdulazeem-code:mainfrom
Tijesunimi004:refactor/dedupe-fallback-check

Conversation

@Tijesunimi004

Copy link
Copy Markdown
Contributor

Closes #587.

What changed

shouldFallbackToLocalRegistry — the check that decides whether a Prisma error means "database unreachable, use the local registry fallback" — was copy-pasted into src/routes/v1/webhookRoutes.js and src/webhookWorker.js. The three copies (those two plus the canonical one in src/utils.js) were byte-identical apart from a blank line.

  • Removed both local definitions.
  • Both files now import shouldFallbackToLocalRegistry from src/utils.js, the same source server.js, src/routes/v1/userRoutes.js, and src/services/statsService.js already use.
  • src/utils.js has no imports of its own, so this introduces no dependency cycle.

No behaviour change — the consolidated implementation is identical to what each file was already running.

Incidental

Dropped a dead let userRecord = null initializer in webhookRoutes.js (userRecord is reassigned on every path before it is read). eslint's no-useless-assignment flags it as an error, and the pre-commit hook lints the whole staged file, so the line had to go for the commit to land.

Acceptance criteria

  • Single source of truth — src/utils.js
  • All route files import from src/utils.js
  • No duplicate definitions remain (grep -rn 'const shouldFallbackToLocalRegistry =' src server.js → only src/utils.js)
  • Tests pass — full backend suite green (--runInBand: 671/671)

Note on the parallel test run

Running npm test with the default parallel workers, sql-injection.test.js intermittently fails two cases (#35 Injection safety — GET /federation). This reproduces identically on a clean upstream/main checkout, passes in isolation (32/32) and under --runInBand (671/671), and is green on CI. It is a pre-existing cross-file test-isolation flake, unrelated to this change.

The Prisma-connection fallback check was copy-pasted, byte-identical
apart from whitespace, in webhookRoutes.js and webhookWorker.js. Both
now import the canonical implementation from src/utils.js, which
server.js, userRoutes.js and statsService.js already use. No behaviour
change.

Also drops a dead `let userRecord = null` initializer in
webhookRoutes.js that eslint's no-useless-assignment flags as an error;
the pre-commit hook lints the whole file.
Copilot AI lite review requested due to automatic review settings August 29, 2026 15:46
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Tijesunimi004 is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Tijesunimi004 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

@Abdulazeem-code
Abdulazeem-code merged commit 776a946 into Abdulazeem-code:main Aug 29, 2026
8 of 10 checks passed
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.

Eliminate duplicate shouldFallbackToLocalRegistry implementations

3 participants