fix: linkedin sync broken due to apify schema changes#889
Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| companies: [ | ||
| `https://www.linkedin.com/company/${companyNameOrLinkedInId}`, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
Company lookup broken when using company names
High Severity
The saveCompanyIfNecessary function accepts both company names and LinkedIn IDs (as indicated by the parameter name and database query), but the new URL construction assumes the input is always a LinkedIn ID or slug. When called from offers.ts with human-readable company names like "Google" or "The Walt Disney Company", the constructed URL https://www.linkedin.com/company/${companyNameOrLinkedInId} will likely fail since company display names rarely match their LinkedIn universal names exactly. Additionally, company names with spaces aren't URL-encoded, creating malformed URLs. This breaks the offer creation flow for any company not already in the database.
| await Promise.all( | ||
| newResults.map(async (result) => { | ||
| if (result.element) { | ||
| if (!result.error) { |
There was a problem hiding this comment.
Cache key unchanged despite schema change causing parse failures
High Severity
The cache key version remains v2 despite the schema change from element-wrapped structure to flat structure. Cached data from before this change has the old format (e.g., { element: { education: [...] } }), but LinkedInResult.parse(value) at line 652 now expects the new flat format. This causes Zod parse errors when processing members with old cached profiles. Since there's no try-catch around the parse and it's inside Promise.all, the entire batch fails. The cache key version needs to be incremented (e.g., to v3) to invalidate stale cached data.
Description ✏️
This PR fixes an issue with the LinkedIn sync that is due to schema changes that happened with the Apify actor. Not sure why they changed it or if we can pin it somehow but this is a quick fix.
Type of Change 🐞
Checklist ✅
Note
Aligns LinkedIn sync with Apify’s updated response shape and fixes company scraping input.
LinkedInProfile/LinkedInFailureschemas: removeelementnesting; add top-leveleducation/experience/photo/headline/location;Failurenow includeserrorarrayerroras success and to read fields from the new top-level paths (education, experience, location, headline, photo)!profile.elementwithprofile.errorand updates all downstream uses (processProfile,checkMember, etc.)runActorbody (companies: ["https://www.linkedin.com/company/${id}"])Written by Cursor Bugbot for commit 9694441. This will update automatically on new commits. Configure here.