Skip to content

fix(cache): invalidate link resolution cache on update and delete#21

Open
RaoUsama7 wants to merge 1 commit intoLinkForty:mainfrom
RaoUsama7:fix/client-ip-followup
Open

fix(cache): invalidate link resolution cache on update and delete#21
RaoUsama7 wants to merge 1 commit intoLinkForty:mainfrom
RaoUsama7:fix/client-ip-followup

Conversation

@RaoUsama7
Copy link
Contributor

Description

Small follow-up fix based on prior review feedback.

This change improves type safety in the client IP helper and corrects missing-IP fallback behavior so installs without an IP do not accidentally match on the IP fingerprint factor.

Changes Made

  • Replace (request as any).socket?.remoteAddress with request.raw.socket?.remoteAddress
  • Replace 'unknown' fallback with empty string ''
  • Update tests to reflect the new behavior

Why this matters

Using 'unknown' as a fallback is truthy and could allow two no-IP installs to match on the IP component of fingerprint scoring.

Returning '' instead ensures the IP comparison is skipped when no trusted IP is available.

Testing

  • All tests passing locally

- Add reusable helper for Redis link-resolution cache invalidation
- Invalidate cached keys after successful link update and delete
- Clear both old and new key sets when template association changes
- Add unit tests for cache invalidation helper behavior
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant