jackwener/OpenCLI · error · CommandExecutionError

LinkedIn jobs preferences could not find stable preferences

Error message

LinkedIn jobs preferences could not find stable preferences content

What it means

Thrown by normalizePreferences when both normalized preferenceText and alertText are empty — i.e. raw_preferences was blank in both payloads. Unlike the malformed-payload guards, the objects were well-formed but contained no stable textual content to derive open_to_work or preferences columns from.

Source

Thrown at clis/linkedin/jobs-preferences.js:73

    return {
      alerts_url: location.href,
      job_alerts: Array.from(new Set(alerts)).slice(0, 20),
      raw_preferences: clean(text).slice(0, 3000),
    };
  })()`;
}

function normalizePreferences(preferences, alerts) {
  if (!preferences || typeof preferences !== 'object') {
    throw new CommandExecutionError('LinkedIn jobs preferences returned malformed preferences payload');
  }
  if (!alerts || typeof alerts !== 'object') {
    throw new CommandExecutionError('LinkedIn jobs preferences returned malformed alerts payload');
  }
  const preferenceText = normalizeWhitespace(preferences.raw_preferences);
  const alertText = normalizeWhitespace(alerts.raw_preferences);
  if (!preferenceText && !alertText) {
    throw new CommandExecutionError('LinkedIn jobs preferences could not find stable preferences content');
  }
  return {
    open_to_work: inferOpenToWork(`${preferenceText} ${alertText}`),
    job_titles: Array.isArray(preferences.job_titles) ? preferences.job_titles.map(normalizeWhitespace).filter(Boolean).join('; ') : '',
    locations: Array.isArray(preferences.locations) ? preferences.locations.map(normalizeWhitespace).filter(Boolean).join('; ') : '',
    job_alerts: Array.isArray(alerts.job_alerts) ? alerts.job_alerts.map(normalizeWhitespace).filter(Boolean).join('; ') : '',
    preferences_url: normalizeWhitespace(preferences.preferences_url),
    alerts_url: normalizeWhitespace(alerts.alerts_url),
    raw_preferences: preferenceText.slice(0, 1200),
  };
}

cli({
  site: 'linkedin',
  name: 'jobs-preferences',
  access: 'read',
  description: 'Read visible LinkedIn Jobs preferences and alert settings without changing them',
  domain: 'www.linkedin.com',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Configure job preferences and alerts on LinkedIn so the page has content to extract
  2. Increase page.wait after both gotos so content renders before evaluate
  3. Update the extraction script selectors to the current LinkedIn DOM if content exists visually
  4. Treat the empty case as a valid empty result instead of throwing if your use case allows it

Example fix

// before
if (!preferenceText && !alertText) {
  throw new CommandExecutionError('LinkedIn jobs preferences could not find stable preferences content');
}
// after
if (!preferenceText && !alertText) {
  return { open_to_work: false, job_titles: '', locations: '', job_alerts: '', preferences_url: PREFERENCES_URL, alerts_url: ALERTS_URL, raw_preferences: '' };
}
Defensive patterns

Strategy: fallback

Validate before calling

const preferenceText = (preferences && typeof preferences.raw_preferences === 'string') ? preferences.raw_preferences.trim() : '';
const alertText = (alerts && typeof alerts.raw_preferences === 'string') ? alerts.raw_preferences.trim() : '';
if (!preferenceText && !alertText) {
  console.warn('No preferences content found; returning empty defaults');
}

Type guard

function hasPreferencesContent(preferences, alerts) {
  return Boolean((preferences && String(preferences.raw_preferences || '').trim()) || (alerts && String(alerts.raw_preferences || '').trim()));
}

Try / catch

try {
  return out(normalizePreferences(preferences, alerts));
} catch (err) {
  if (String(err.message).includes('could not find stable preferences content')) {
    return out({ open_to_work: false, job_titles: '', locations: '', job_alerts: '', preferences_url: PREFERENCES_URL, alerts_url: ALERTS_URL, raw_preferences: '' });
  }
  throw err;
}

Prevention

When it happens

Trigger: Both preferences.raw_preferences and alerts.raw_preferences normalize to empty strings: profile has no job preferences set and no alert preferences, or the extraction script grabbed an empty container.

Common situations: Fresh/empty LinkedIn profile with Open-to-Work and preferences never configured; extraction script targeting a container that is now empty after a LinkedIn UI change; page captured before content rendered.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/30cb18a4534bc8c0. Report an issue: GitHub.