{"record":{"id":"86840e03190f90a5","repo":"agalwood/Motrix","slug":"invalid-chrome-extension-id-id","errorCode":null,"errorMessage":"invalid Chrome extension ID: ${id}","messagePattern":"invalid Chrome extension ID: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/bridge/trusted-extension-registry.ts","lineNumber":24,"sourceCode":"  id: string\n  browser: Browser\n  source: TrustSource\n  label?: string\n  addedAt: number\n}\n\nexport interface RegistryStore {\n  read(): Promise<string | null>\n  write(content: string): Promise<void>\n}\n\nconst CHROME_ID_RE = /^[a-p]{32}$/\nconst FIREFOX_ID_RE = /^([^@\\s]+@[^@\\s]+|\\{[0-9a-fA-F-]{36}\\})$/\n\nfunction validateId(id: string, browser: Browser): void {\n  if (browser === 'chromium') {\n    if (!CHROME_ID_RE.test(id)) {\n      throw new Error(`invalid Chrome extension ID: ${id}`)\n    }\n  } else {\n    if (!FIREFOX_ID_RE.test(id)) {\n      throw new Error(`invalid Firefox extension ID: ${id}`)\n    }\n  }\n}\n\nexport class TrustedExtensionRegistry {\n  private entries = new Map<string, TrustedExtension>()\n  private builtinIds = new Set<string>()\n\n  constructor(\n    private store: RegistryStore,\n    private builtin: Array<{ id: string; browser: Browser }>\n  ) {}\n\n  async load(): Promise<void> {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/agalwood/Motrix/blob/1a708ee57746c434e2c67a44bbf0906a976afea4/src/core/bridge/trusted-extension-registry.ts#L6-L42","documentation":"Thrown by validateId() inside TrustedExtensionRegistry when a Chromium extension ID fails the regex /^[a-p]{32}$/ (exactly 32 lowercase characters in the range a-p, which is the base-16-p letters encoding Chrome uses for extension IDs). Reached via registry.add() for user-added/imported entries, and also during load() where invalid entries are silently skipped. This is a plain Error (no error code), thrown before the entry is persisted.","triggerScenarios":"TrustedExtensionRegistry.add(id, 'chromium', source, label?) is called with an id that is not exactly 32 characters of [a-p]: wrong length, uppercase letters, characters outside a-p, or empty string.","commonSituations":"A user manually enters an extension ID with a typo; an imported registry file contains a corrupted/malformed Chrome ID; confusing a Chrome extension ID (32 chars a-p) with a Firefox ID (email or UUID format); copying an ID with extra whitespace or hyphens.","solutions":["Verify the Chrome extension ID is exactly 32 lowercase characters from a-p (find it in chrome://extensions or the Web Store URL)","Strip whitespace and normalize case before calling add()","If the ID is actually a Firefox extension, pass browser: 'firefox' instead of 'chromium'","Validate with the same regex before calling add() to give a better error message to the user"],"exampleFix":"// before\nawait registry.add('abcdefghijklmnopqrstuvwx', 'chromium', 'user-added')\n// after\nawait registry.add('abcdefghijklmnopqrstuvwxyz012345', 'chromium', 'user-added') // 32 chars a-p","handlingStrategy":"validation","validationCode":"const CHROME_ID_RE = /^[a-p]{32}$/\nfunction isValidChromeId(id: string): boolean {\n  return CHROME_ID_RE.test(id)\n}\n// Before add:\nif (!isValidChromeId(id)) {\n  throw new Error(`Invalid Chrome extension ID (need 32 chars a-p): ${id}`)\n}","typeGuard":"function isChromeExtensionId(id: string): boolean {\n  return /^[a-p]{32}$/.test(id)\n}","tryCatchPattern":"try {\n  await registry.add(id, 'chromium', 'user-added', label)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('invalid Chrome extension ID')) {\n    showUserError('Enter a valid Chrome extension ID (32 characters, a-p only)')\n  } else throw e\n}","preventionTips":["Copy Chrome extension IDs directly from chrome://extensions (enable Developer Mode) or the Web Store URL","Validate with /^[a-p]{32}$/ in the UI input field before submission","Strip whitespace before validation"],"tags":["validation","extension","chrome","registry","regex"],"backgroundTag":null,"analyzedSha":"1a708ee57746c434e2c67a44bbf0906a976afea4","analyzedAt":"2026-08-12T16:18:09.346Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}