Skip to content

fix: support LinkedIn URL contact lookup#214

Merged
michaelmwu merged 2 commits into
mainfrom
michaelmwu/linkedin-url-field
Mar 22, 2026
Merged

fix: support LinkedIn URL contact lookup#214
michaelmwu merged 2 commits into
mainfrom
michaelmwu/linkedin-url-field

Conversation

@michaelmwu
Copy link
Copy Markdown
Member

@michaelmwu michaelmwu commented Mar 22, 2026

Description

Treat LinkedIn profile URLs in CRM search_term lookups as exact cLinkedIn matches instead of falling back to name search.
Normalize common LinkedIn profile URL variants so stored www and non-www forms can both resolve the same contact.
Add unit coverage for full and bare LinkedIn profile URL inputs.

Related Issue

N/A

How Has This Been Tested?

uv run pytest tests/unit/test_crm.py -k "build_contact_search_filters or search_contacts_for_lookup_includes_discord_username_filter_when_requested or search_contacts_by_field_includes_requested_field_and_excludes_default"

Summary by CodeRabbit

  • New Features
    • Added LinkedIn profile URL support for CRM contact lookup. Users can now search contacts by LinkedIn profile URLs, with automatic normalization of various URL formats.

Copilot AI review requested due to automatic review settings March 22, 2026 22:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Warning

Rate limit exceeded

@michaelmwu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 379ef297-7050-4e19-a1a6-3ff9b52dd074

📥 Commits

Reviewing files that changed from the base of the PR and between 1dc6a73 and b13b4f8.

📒 Files selected for processing (2)
  • apps/discord_bot/src/five08/discord_bot/cogs/crm.py
  • tests/unit/test_crm.py
📝 Walkthrough

Walkthrough

The pull request adds LinkedIn profile URL normalization and validation to the Discord bot's CRM cog. A new private helper method validates LinkedIn URLs, normalizes variants (with/without HTTPS scheme, www subdomain, trailing slashes), and returns deduplicated forms for exact matching. The search filter logic is updated to use these variants for precise LinkedIn lookups via equality filters.

Changes

Cohort / File(s) Summary
LinkedIn URL Normalization
apps/discord_bot/src/five08/discord_bot/cogs/crm.py
Added urllib.parse.urlsplit import and new _linkedin_profile_search_variants() method to validate and normalize LinkedIn profile URLs. Updated _build_contact_search_filters() to generate equals-type filters using normalized URL variants for CRM LinkedIn field lookups.
Unit Tests
tests/unit/test_crm.py
Added two test cases validating _build_contact_search_filters() behavior for LinkedIn URLs: one for full https://www.linkedin.com/in/... URLs and one for bare linkedin.com/in/... forms, ensuring correct normalization and filter generation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through links with care,
Validating URLs with flair,
LinkedIn profiles now shine so bright,
Normalized paths set everything right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: support LinkedIn URL contact lookup' directly and clearly summarizes the main change: adding LinkedIn URL support to the CRM contact lookup functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michaelmwu/linkedin-url-field

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates CRM contact lookup behavior so LinkedIn profile URLs are treated as exact cLinkedIn matches (with normalized URL variants), avoiding fallback to name-based searching and improving match reliability across common stored URL formats.

Changes:

  • Add LinkedIn profile URL detection + generation of normalized exact-match URL variants for lookup.
  • Update _build_contact_search_filters to prefer cLinkedIn equality filters when a LinkedIn profile URL is provided.
  • Add unit tests covering full and bare LinkedIn profile URL inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/discord_bot/src/five08/discord_bot/cogs/crm.py Adds LinkedIn URL variant normalization and uses it to build cLinkedIn exact-match filters during lookup.
tests/unit/test_crm.py Adds unit coverage validating LinkedIn URL inputs produce cLinkedIn filters (and avoid name filters).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/discord_bot/src/five08/discord_bot/cogs/crm.py
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/test_crm.py (1)

3718-3728: Strengthen bare-URL assertions to fully enforce cLinkedIn variant behavior.

At Line 3722 and Line 3727, the test checks one normalized value and no name filter, but it can still pass if other non-cLinkedIn filters leak in or if the bare input doesn’t produce the www variant.

Suggested test hardening
 def test_build_contact_search_filters_bare_linkedin_profile_url(self, crm_cog):
     """Build shared search filters for bare LinkedIn profile URLs."""
     filters = crm_cog._build_contact_search_filters("linkedin.com/in/hshidara")
 
+    assert all(filter_["attribute"] == "cLinkedIn" for filter_ in filters)
     assert {
         "type": "equals",
         "attribute": "cLinkedIn",
         "value": "https://linkedin.com/in/hshidara",
     } in filters
+    assert {
+        "type": "equals",
+        "attribute": "cLinkedIn",
+        "value": "https://www.linkedin.com/in/hshidara",
+    } in filters
     assert not any(filter_["attribute"] == "name" for filter_ in filters)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/test_crm.py` around lines 3718 - 3728, Update the
test_build_contact_search_filters_bare_linkedin_profile_url to call
crm_cog._build_contact_search_filters and assert that the returned filters
include both normalized cLinkedIn variants ("https://linkedin.com/in/hshidara"
and "https://www.linkedin.com/in/hshidara") and that every filter with attribute
"cLinkedIn" uses only those normalized values, while also asserting there are no
filters whose attribute is not "cLinkedIn" (to prevent leaks) and still
asserting no filter has attribute "name".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/discord_bot/src/five08/discord_bot/cogs/crm.py`:
- Around line 4736-4745: The variants list creation (variables: variants,
variant, value, path) currently adds only the raw scheme-less input and
scheme-prefixed URLs; add scheme-less cross-variants for both www and non-www
forms so CRM lookups match stored entries without a scheme. Update the loop that
builds variants in crm.py (around the block that iterates over (value.strip(),
f"https://linkedin.com{path}", ...)) to also include f"www.linkedin.com{path}"
and f"linkedin.com{path}" (or their non-www equivalents) as separate scheme-less
entries, ensuring you still deduplicate via the existing if variant and variant
not in variants check. Ensure ordering and dedupe logic remain the same.

---

Nitpick comments:
In `@tests/unit/test_crm.py`:
- Around line 3718-3728: Update the
test_build_contact_search_filters_bare_linkedin_profile_url to call
crm_cog._build_contact_search_filters and assert that the returned filters
include both normalized cLinkedIn variants ("https://linkedin.com/in/hshidara"
and "https://www.linkedin.com/in/hshidara") and that every filter with attribute
"cLinkedIn" uses only those normalized values, while also asserting there are no
filters whose attribute is not "cLinkedIn" (to prevent leaks) and still
asserting no filter has attribute "name".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7fd9ae6e-8da1-4a90-9874-b2bd121d81ce

📥 Commits

Reviewing files that changed from the base of the PR and between cc87673 and 1dc6a73.

📒 Files selected for processing (2)
  • apps/discord_bot/src/five08/discord_bot/cogs/crm.py
  • tests/unit/test_crm.py

Comment thread apps/discord_bot/src/five08/discord_bot/cogs/crm.py
@michaelmwu michaelmwu merged commit d9012c1 into main Mar 22, 2026
5 checks passed
@michaelmwu michaelmwu deleted the michaelmwu/linkedin-url-field branch March 22, 2026 22:41
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.

2 participants